From 5d79931bb062bb3f851a566dfe0104abdc6c3db6 Mon Sep 17 00:00:00 2001 From: "David E. O'Brien" Date: Tue, 24 Jul 2001 14:06:19 +0000 Subject: [PATCH] Expand emalloc in-place, and remove the `rname' basename() implimenation. --- usr.bin/ranlib/build.c | 10 ++++++---- usr.bin/ranlib/misc.c | 20 -------------------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/usr.bin/ranlib/build.c b/usr.bin/ranlib/build.c index b4d8bc69a8e..6768257b658 100644 --- a/usr.bin/ranlib/build.c +++ b/usr.bin/ranlib/build.c @@ -143,7 +143,6 @@ rexec(rfd, wfd) struct nlist nl; off_t r_off, w_off; long strsize; - void *emalloc(); /* Get current offsets for original and tmp files. */ r_off = lseek(rfd, (off_t)0, SEEK_CUR); @@ -169,7 +168,8 @@ rexec(rfd, wfd) /* Read in the string table. */ strsize -= sizeof(strsize); - strtab = emalloc(strsize); + if ((strtab = malloc(strsize)) == NULL) + error(archive); nr = read(rfd, strtab, strsize); if (nr != strsize) { badread: if (nr < 0) @@ -205,8 +205,10 @@ badread: if (nr < 0) sym = strtab + nl.n_un.n_strx - sizeof(long); symlen = strlen(sym) + 1; - rp = (RLIB *)emalloc(sizeof(RLIB)); - rp->sym = (char *)emalloc(symlen); + if ((rp = malloc(sizeof(RLIB))) == NULL) + error(archive); + if ((rp->sym = malloc(symlen)) == NULL) + error(archive); bcopy(sym, rp->sym, symlen); rp->symlen = symlen; rp->pos = w_off; diff --git a/usr.bin/ranlib/misc.c b/usr.bin/ranlib/misc.c index 19b4854cbfa..85a5f8cfbc4 100644 --- a/usr.bin/ranlib/misc.c +++ b/usr.bin/ranlib/misc.c @@ -79,26 +79,6 @@ tmp(void) return(fd); } -void * -emalloc(len) - int len; -{ - void *p; - - if ((p = malloc((u_int)len)) == NULL) - error(archive); - return(p); -} - -char * -rname(path) - char *path; -{ - register char *ind; - - return((ind = rindex(path, '/')) ? ind + 1 : path); -} - void badfmt(void) {