summaryrefslogtreecommitdiffstats
path: root/usr.bin/find
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2001-07-24 14:12:05 +0000
committerobrien <obrien@FreeBSD.org>2001-07-24 14:12:05 +0000
commit44717cb5e9e4bbe75c712670e0fa44ef7711aad7 (patch)
tree406ef9426f8d043031e8e848c605676a503dd041 /usr.bin/find
parent56240ae8081096f64098bd2841787849ff947763 (diff)
downloadFreeBSD-src-44717cb5e9e4bbe75c712670e0fa44ef7711aad7.zip
FreeBSD-src-44717cb5e9e4bbe75c712670e0fa44ef7711aad7.tar.gz
Remove emalloc and expand to the malloc + error checking it was, where used.
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/extern.h1
-rw-r--r--usr.bin/find/function.c13
-rw-r--r--usr.bin/find/misc.c15
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);
-}
OpenPOWER on IntegriCloud