diff options
-rw-r--r-- | usr.bin/find/extern.h | 1 | ||||
-rw-r--r-- | usr.bin/find/function.c | 13 | ||||
-rw-r--r-- | usr.bin/find/misc.c | 15 |
3 files changed, 9 insertions, 20 deletions
diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h index f200786..2528a37 100644 --- a/usr.bin/find/extern.h +++ b/usr.bin/find/extern.h @@ -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 **)); diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index a60c4c4..1de472b 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -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; } diff --git a/usr.bin/find/misc.c b/usr.bin/find/misc.c index 36045a3..6e19403 100644 --- a/usr.bin/find/misc.c +++ b/usr.bin/find/misc.c @@ -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); -} |