summaryrefslogtreecommitdiffstats
path: root/usr.bin/hexdump/parse.c
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2001-07-24 14:11:09 +0000
committerobrien <obrien@FreeBSD.org>2001-07-24 14:11:09 +0000
commit56240ae8081096f64098bd2841787849ff947763 (patch)
tree99869b2819c3150fc72486ff077726d749cc31b4 /usr.bin/hexdump/parse.c
parent0004ccf79876c8bdda19ea656a8360faae38bd8c (diff)
downloadFreeBSD-src-56240ae8081096f64098bd2841787849ff947763.zip
FreeBSD-src-56240ae8081096f64098bd2841787849ff947763.tar.gz
Remove the misnamed `emalloc' and replace its uses with the calloc (along
with error checking) that it actually was.
Diffstat (limited to 'usr.bin/hexdump/parse.c')
-rw-r--r--usr.bin/hexdump/parse.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/hexdump/parse.c b/usr.bin/hexdump/parse.c
index d02cd09..c05d568 100644
--- a/usr.bin/hexdump/parse.c
+++ b/usr.bin/hexdump/parse.c
@@ -87,7 +87,8 @@ add(fmt)
FU *tfu, **nextfu;
/* start new linked list of format units */
- tfs = emalloc(sizeof(FS));
+ if ((tfs = calloc(1, sizeof(FS))) == NULL)
+ err(1, NULL);
if (!fshead)
fshead = tfs;
else
@@ -103,7 +104,8 @@ add(fmt)
break;
/* allocate a new format unit and link it in */
- tfu = emalloc(sizeof(FU));
+ if ((tfu = calloc(1, sizeof(FU))) == NULL)
+ err(1, NULL);
*nextfu = tfu;
nextfu = &tfu->nextfu;
tfu->reps = 1;
@@ -141,7 +143,7 @@ add(fmt)
if (*p++ == 0)
badfmt(fmt);
if (!(tfu->fmt = malloc(p - savep + 1)))
- nomem();
+ err(1, NULL);
(void) strncpy(tfu->fmt, savep, p - savep);
tfu->fmt[p - savep] = '\0';
escape(tfu->fmt);
@@ -222,7 +224,8 @@ rewrite(fs)
* character gets its own.
*/
for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {
- pr = emalloc(sizeof(PR));
+ if ((pr = calloc(1, sizeof(PR))) == NULL)
+ err(1, NULL);
if (!fu->nextpr)
fu->nextpr = pr;
else
@@ -385,7 +388,8 @@ isint2: switch(fu->bcnt) {
*/
savech = *p2;
p1[0] = '\0';
- pr->fmt = emalloc(strlen(fmtp) + 2);
+ if ((pr->fmt = calloc(1, strlen(fmtp) + 2)) == NULL)
+ err(1, NULL);
(void)strcpy(pr->fmt, fmtp);
(void)strcat(pr->fmt, cs);
*p2 = savech;
OpenPOWER on IntegriCloud