Remove emalloc and expand to the malloc + error checking it was, where used.
This commit is contained in:
parent
ac3c230c82
commit
f0cb953721
@ -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 **));
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user