summaryrefslogtreecommitdiffstats
path: root/usr.bin/hexdump
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
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')
-rw-r--r--usr.bin/hexdump/display.c24
-rw-r--r--usr.bin/hexdump/hexdump.h2
-rw-r--r--usr.bin/hexdump/parse.c14
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;
OpenPOWER on IntegriCloud