Remove emalloc and expand to the malloc + error checking it was, where used.

This commit is contained in:
David E. O'Brien 2001-07-24 14:12:05 +00:00
parent ac3c230c82
commit f0cb953721
3 changed files with 9 additions and 20 deletions

View File

@ -37,7 +37,6 @@
#include <sys/cdefs.h>
void brace_subst __P((char *, char **, char *, int));
void *emalloc __P((unsigned int));
PLAN *find_create __P((char ***));
int find_execute __P((PLAN *, char **));
PLAN *find_formplan __P((char **));

View File

@ -515,15 +515,20 @@ c_exec(option, argvp)
}
cnt = ap - *argvp + 1;
new->e_argv = (char **)emalloc((u_int)cnt * sizeof(char *));
new->e_orig = (char **)emalloc((u_int)cnt * sizeof(char *));
new->e_len = (int *)emalloc((u_int)cnt * sizeof(int));
if ((new->e_argv = malloc((u_int)cnt * sizeof(char *))) == NULL)
err(1, (char *)NULL);
if ((new->e_orig = malloc((u_int)cnt * sizeof(char *))) == NULL)
err(1, (char *)NULL);
if ((new->e_len = malloc((u_int)cnt * sizeof(int))) == NULL)
err(1, (char *)NULL);
for (argv = *argvp, cnt = 0; argv < ap; ++argv, ++cnt) {
new->e_orig[cnt] = *argv;
for (p = *argv; *p; ++p)
if (p[0] == '{' && p[1] == '}') {
new->e_argv[cnt] = emalloc((u_int)MAXPATHLEN);
if ((new->e_argv[cnt] =
malloc((u_int)MAXPATHLEN)) == NULL)
err(1, (char *)NULL);
new->e_len[cnt] = MAXPATHLEN;
break;
}

View File

@ -115,18 +115,3 @@ queryuser(argv)
}
return (first == 'y');
}
/*
* emalloc --
* malloc with error checking.
*/
void *
emalloc(len)
u_int len;
{
void *p;
if ((p = malloc(len)) == NULL)
err(1, NULL);
return (p);
}