diff options
Diffstat (limited to 'usr.bin/hexdump')
-rw-r--r-- | usr.bin/hexdump/display.c | 24 | ||||
-rw-r--r-- | usr.bin/hexdump/hexdump.h | 2 | ||||
-rw-r--r-- | usr.bin/hexdump/parse.c | 14 |
3 files changed, 14 insertions, 26 deletions
diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c index 982e611..1b28196 100644 --- a/usr.bin/hexdump/display.c +++ b/usr.bin/hexdump/display.c @@ -238,8 +238,10 @@ get() u_char *tmpp; if (!curp) { - curp = emalloc(blocksize); - savp = emalloc(blocksize); + if ((curp = calloc(1, blocksize)) == NULL) + err(1, NULL); + if ((savp = calloc(1, blocksize)) == NULL) + err(1, NULL); } else { tmpp = curp; curp = savp; @@ -366,21 +368,3 @@ doskip(fname, statok) skip -= cnt; } } - -void * -emalloc(size) - int size; -{ - void *p; - - if ((p = malloc((u_int)size)) == NULL) - nomem(); - bzero(p, size); - return(p); -} - -void -nomem() -{ - err(1, NULL); -} diff --git a/usr.bin/hexdump/hexdump.h b/usr.bin/hexdump/hexdump.h index 165673a..1856618 100644 --- a/usr.bin/hexdump/hexdump.h +++ b/usr.bin/hexdump/hexdump.h @@ -31,6 +31,7 @@ * SUCH DAMAGE. * * @(#)hexdump.h 8.1 (Berkeley) 6/6/93 + * $FreeBSD$ */ typedef struct _pr { @@ -85,7 +86,6 @@ void conv_c __P((PR *, u_char *)); void conv_u __P((PR *, u_char *)); void display __P((void)); void doskip __P((char *, int)); -void *emalloc __P((int)); void escape __P((char *)); u_char *get __P((void)); void newsyntax __P((int, char ***)); 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; |