diff options
author | brian <brian@FreeBSD.org> | 1998-08-21 18:10:15 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1998-08-21 18:10:15 +0000 |
commit | e33077d21e0550e4887d7fa99f119879173013b1 (patch) | |
tree | c341efe7472b9678c995e827868858b9979aa5d6 /usr.sbin/ppp/mbuf.c | |
parent | 016635b3542cbeba3d19d3dacda50ee7ebfcc1a9 (diff) | |
download | FreeBSD-src-e33077d21e0550e4887d7fa99f119879173013b1.zip FreeBSD-src-e33077d21e0550e4887d7fa99f119879173013b1.tar.gz |
Consolidate the two malloc()s that are done when allocating
an mbuf.
Diffstat (limited to 'usr.sbin/ppp/mbuf.c')
-rw-r--r-- | usr.sbin/ppp/mbuf.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/usr.sbin/ppp/mbuf.c b/usr.sbin/ppp/mbuf.c index a4014c6..9156d3b 100644 --- a/usr.sbin/ppp/mbuf.c +++ b/usr.sbin/ppp/mbuf.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: mbuf.c,v 1.19 1998/08/07 18:42:50 brian Exp $ + * $Id: mbuf.c,v 1.20 1998/08/21 18:09:57 brian Exp $ * */ #include <sys/types.h> @@ -56,27 +56,20 @@ mbuf_Length(struct mbuf * bp) struct mbuf * mbuf_Alloc(int cnt, int type) { - u_char *p; struct mbuf *bp; if (type > MB_MAX) log_Printf(LogERROR, "Bad mbuf type %d\n", type); - bp = (struct mbuf *) malloc(sizeof(struct mbuf)); + bp = malloc(sizeof(struct mbuf) + cnt); if (bp == NULL) { log_Printf(LogALERT, "failed to allocate memory: %ld\n", (long)sizeof(struct mbuf)); AbortProgram(EX_OSERR); } memset(bp, '\0', sizeof(struct mbuf)); - p = (u_char *) malloc(cnt); - if (p == NULL) { - log_Printf(LogALERT, "failed to allocate memory: %d\n", cnt); - AbortProgram(EX_OSERR); - } MemMap[type].fragments++; MemMap[type].octets += cnt; totalalloced += cnt; - bp->base = p; bp->size = bp->cnt = cnt; bp->type = type; bp->pnext = NULL; @@ -93,7 +86,6 @@ mbuf_FreeSeg(struct mbuf * bp) MemMap[bp->type].fragments--; MemMap[bp->type].octets -= bp->size; totalalloced -= bp->size; - free(bp->base); free(bp); return (nbp); } |