/* 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 20000 /* yikes! */ #define log my_log #ifdef MEMORY_DEBUGGING #define DEBUG #endif #if HAVE_CONFIG_H #include #endif #include #include #include extern int serv; unsigned memused=0; #ifdef DEBUG struct { void *ptr; short size; char file[15]; short line; } memtbl[MEMTBLSIZE]; #endif void mprintf(); void dprintf(); void my_log(); int expected_memory(); int expmem_chan(); int expmem_chanprog(); int expmem_misc(); int expmem_fileq(); int expmem_users(); int expmem_proc(); int expmem_dccutil(); int expmem_tandem(); #ifdef TCL int expmem_tcl(); int expmem_tclhash(); #endif /* 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 } void *n_malloc(size,file,line) int size,line; char *file; { void *x; #ifdef DEBUG int i; x=(void *)malloc(size); if (x==NULL) { log(LOG_MISC,"*** FAILED MALLOC %s (%d)",file,line); return NULL; } for (i=0; (i