summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2001-07-24 14:08:02 +0000
committerobrien <obrien@FreeBSD.org>2001-07-24 14:08:02 +0000
commitf842b779c36c44bc686f6d57b2392f5fdb3fd25b (patch)
treeacde13a004d688b91491266c308ce0aa484d690e /usr.bin
parent9032757ec8b632bf62151d42b7016465752f99c3 (diff)
downloadFreeBSD-src-f842b779c36c44bc686f6d57b2392f5fdb3fd25b.zip
FreeBSD-src-f842b779c36c44bc686f6d57b2392f5fdb3fd25b.tar.gz
Expland the emalloc to do the testing at the place of mallocing.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/nm/nm.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/usr.bin/nm/nm.c b/usr.bin/nm/nm.c
index c18830d..5bad221 100644
--- a/usr.bin/nm/nm.c
+++ b/usr.bin/nm/nm.c
@@ -79,7 +79,6 @@ int (*sfunc)() = fname;
#define SYMBOL_TYPE(x) ((x) & (N_TYPE | N_STAB))
#define SYMBOL_BIND(x) (((x) >> 4) & 0xf)
-void *emalloc();
static void usage __P(( void ));
int process_file __P(( char * ));
int show_archive __P(( char *, FILE * ));
@@ -232,7 +231,8 @@ show_archive(fname, fp)
char *p, *name, *ar_name;
int extra = strlen(fname) + 3;
- name = emalloc(MAXNAMLEN + extra);
+ if ((name = malloc(MAXNAMLEN + extra)) == NULL)
+ err(1, NULL);
ar_name = name + extra;
rval = 0;
@@ -381,7 +381,8 @@ show_objfile(objname, fp)
}
/* get memory for the symbol table */
- names = emalloc((size_t)head.a_syms);
+ if ((names = malloc((size_t)head.a_syms)) == NULL)
+ err(1, NULL);
nrawnames = head.a_syms / sizeof(*names);
if (fread((char *)names, (size_t)head.a_syms, (size_t)1, fp) != 1) {
warnx("%s: cannot read symbol table", objname);
@@ -399,7 +400,8 @@ show_objfile(objname, fp)
(void)free((char *)names);
return(1);
}
- stab = emalloc((size_t)stabsize);
+ if ((stab = malloc((size_t)stabsize)) == NULL)
+ err(1, NULL);
/*
* read the string table offset by 4 - all indices into the string
@@ -654,18 +656,6 @@ value(a0, b0)
}
}
-void *
-emalloc(size)
- size_t size;
-{
- char *p;
-
- /* NOSTRICT */
- if ( (p = malloc(size)) )
- return(p);
- err(1, NULL);
-}
-
static void
usage(void)
{
OpenPOWER on IntegriCloud