/* mem.c -- handles: memory allocation and deallocation keeping track of what memory is being used by whom dprintf'ized, 15nov95 */ #define LOG_MISC 32 #define MEMTBLSIZE 25000 /* yikes! */ #ifdef MEMORY_DEBUGGING #define DEBUG #endif #if HAVE_CONFIG_H #include #endif #include #include #include extern int serv; #ifdef DEBUG unsigned long memused=0; struct { void *ptr; short size; char file[15]; short line; } memtbl[MEMTBLSIZE]; #endif void mprintf(); void dprintf(); void putlog(); int expected_memory(); int expmem_chan(); int expmem_chanprog(); int expmem_misc(); int expmem_fileq(); int expmem_users(); int expmem_dccutil(); int expmem_tandem(); int expmem_tcl(); int expmem_tclhash(); int expmem_net(); void tell_netdebug(); /* initialize the memory structure */ void init_mem() { #ifdef DEBUG int i; for (i=0; i60) { sofar[strlen(sofar)-1]=0; dprintf(idx,"%s\n",sofar); strcpy(sofar," "); } } if (sofar[0]) { sofar[strlen(sofar)-1]=0; dprintf(idx,"%s\n",sofar); } } } dprintf(idx,"--- End of debug memory list.\n"); #else dprintf(idx,"Compiled without extensive memory debugging (sorry).\n"); #endif tell_netdebug(idx); } void *n_malloc(size,file,line) int size,line; char *file; { void *x; int i=0; x=(void *)malloc(size); if (x==NULL) { i=i; putlog(LOG_MISC,"*","*** FAILED MALLOC %s (%d)",file,line); return NULL; } #ifdef DEBUG for (i=0; (i