1/* 2 * PPP Memory handling module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * |
20 * $Id: mbuf.c,v 1.7 1997/06/09 03:27:29 brian Exp $ |
21 * 22 */ 23#include <sys/types.h> 24#include <sys/socket.h> 25#include <sys/param.h> 26#include <netinet/in.h> 27#include "defs.h" 28#include "loadalias.h" 29#include "vars.h" |
30#include "server.h" |
31 32struct memmap { 33 struct mbuf *queue; 34 int count; 35} MemMap[MB_MAX+2]; 36 37static int totalalloced; 38 --- 16 unchanged lines hidden (view full) --- 55 u_char *p; 56 struct mbuf *bp; 57 58 if (type > MB_MAX) 59 LogPrintf(LogERROR, "Bad mbuf type %d\n", type); 60 bp = (struct mbuf *)malloc(sizeof(struct mbuf)); 61 if (bp == NULL) { 62 LogPrintf(LogALERT, "failed to allocate memory: %u\n", sizeof(struct mbuf)); |
63 ServerClose(); |
64 exit(1); 65 } 66 bzero(bp, sizeof(struct mbuf)); 67 p = (u_char *)malloc(cnt); 68 if (p == NULL) { 69 LogPrintf(LogALERT, "failed to allocate memory: %d\n", cnt); |
70 ServerClose(); |
71 exit(1); 72 } 73 MemMap[type].count += cnt; 74 totalalloced += cnt; 75 bp->base = p; 76 bp->size = bp->cnt = cnt; 77 bp->type = type; 78 return(bp); --- 99 unchanged lines hidden --- |