/* Copyright K. Mitchell 1995. This file has been generated by a program and is not intended to be read by a human. Run the file occam.w through nuweb. This produces a file called occam.tex. Typeset this file using LaTeX and then preview the resulting .dvi file, or just print it out. */ #include #include #include typedef int bool; #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif #include "occam.h" #include "pool.h" link pool[MAX_POOL_SIZE+1]; link pool_temp; int allocated_pool[MAX_POOL_SIZE+1]; #define NELEM 100 void *extend_pool(int n) { int esize; char *start, *last, *p; esize = (n < 4) ? 4 : n; if ((pool[n] = malloc(NELEM * esize)) == 0) { error("Fatal error", "Memory exhausted\n"); } allocated_pool[n] += NELEM * esize; start = (char *)pool[n]; last = &start[(NELEM-1)*esize]; for (p = start; pnext = (link)(p+esize); ((link)last)->next = NULL; pool[n] = pool[n]->next; return(start); } void pool_statistics() { int i, on_list, in_use; link p; printf("Pool statistics: in use / total (%%)\n"); for (i=1; i <= MAX_POOL_SIZE; i++) { if (allocated_pool[i] == 0) continue; /* Skip unused entries */ p = pool[i]; on_list = 0; while (p) { on_list += i; p = p->next; } in_use = allocated_pool[i] - on_list; printf("%3d: %5d /%5d (%2d%%)\n", i, in_use, allocated_pool[i], 100 * in_use / allocated_pool[i]); } }