1 #include <../../nrnconf.h> 46 static char rcsid[] =
"meminfo.c,v 1.1 1997/12/04 17:55:37 hines Exp";
71 #define MEM_NUM_STD_TYPES (sizeof(mem_type_names)/sizeof(mem_type_names[0])) 111 int (*free_funcs[])();
117 if (type_names ==
NULL || free_funcs ==
NULL 118 || info_sum ==
NULL || ntypes < 0)
122 if ( mem_connect[list].ntypes != 0 )
125 mem_connect[list].
ntypes = ntypes;
128 mem_connect[list].
info_sum = info_sum;
140 mem_connect[list].
ntypes = 0;
158 if ( mem_connect[list].type_names !=
NULL &&
159 mem_connect[list].free_funcs !=
NULL &&
160 mem_connect[list].info_sum !=
NULL)
177 mlist = &mem_connect[list];
178 fprintf(
fp,
" %15s[%d]:\n",
"CONTENTS OF mem_connect",list);
181 "alloc.",
"# alloc.",
186 "bytes",
"variables",
190 for (i=0; i < mlist->
ntypes; i++)
240 || type >= mem_connect[list].ntypes
241 || mem_connect[list].free_funcs[type] ==
NULL )
254 || type >= mem_connect[list].ntypes
255 || mem_connect[list].free_funcs[type] ==
NULL )
278 fprintf(fp,
" MEMORY INFORMATION (standard types):\n");
280 fprintf(fp,
" MEMORY INFORMATION (list no. %d):\n",list);
282 mlist = &mem_connect[list];
284 for (type=0; type < mlist->
ntypes; type++) {
290 fprintf(fp,
" type %-7s %10ld alloc. byte%c %6d alloc. variable%c\n",
291 mlist->
type_names[type], d, (d!=1 ?
's' :
' '),
292 n, (n!=1 ?
's' :
' '));
295 fprintf(fp,
" %-12s %10ld alloc. byte%c %6d alloc. variable%c\n\n",
296 "total:",t, (t!=1 ?
's' :
' '),
297 nt, (nt!=1 ?
's' :
' '));
316 int old_size,new_size;
323 mlist = &mem_connect[list];
324 if ( type < 0 || type >= mlist->
ntypes 328 if ( old_size < 0 || new_size < 0 )
334 if ( old_size > 0 ) {
339 "\n WARNING !! memory info: allocated memory is less than 0\n");
342 if ( !isatty(fileno(stdout)) ) {
344 "\n WARNING !! memory info: allocated memory is less than 0\n");
369 mlist = &mem_connect[list];
370 if ( type < 0 || type >= mlist->
ntypes 382 "\n WARNING !! memory info: allocated # of variables is less than 0\n");
384 if ( !isatty(fileno(stdout)) ) {
386 "\n WARNING !! memory info: allocated # of variables is less than 0\n");
void mem_dump_list(FILE *fp, int list)
#define MEM_CONNECT_MAX_LISTS
void mem_numvar_list(int type, int num, int list)
int mem_attach_list(int list, int ntypes, type_names, int(*[] free_funcs)(), info_sum)
static MEM_ARRAY mem_info_sum[MEM_NUM_STD_TYPES]
int mem_is_list_attached(int list)
int mem_free_vars(int list)
static int(* mem_free_funcs[MEM_NUM_STD_TYPES])()
void mem_bytes_list(int type, int old_size, int new_size, int list)
int const size_t const size_t n
fprintf(stderr, "Don't know the location of params at %p\, pp)
MEM_CONNECT mem_connect[MEM_CONNECT_MAX_LISTS]
long mem_info_bytes(int type, int list)
#define MEM_SWITCH_ON_DEF
#define error(err_num, fn_name)
#define MEM_NUM_STD_TYPES
void mem_info_file(FILE *fp, int list)
static int mem_switched_on
static char * mem_type_names[]
int mem_info_numvar(int type, int list)