#include /* implementing checks which allocated blocks have not been freed. very primitive. to use include m */ int max_allocation = 0 ; void *record_allocation[1000000]; void x_free(void *x) { int ii ; for (ii = 0 ; ii< max_allocation; ii++) if (record_allocation[ii] == x) { record_allocation[ii] = NULL; break ; } free(x) ; } void *x_malloc(int count) { void *new = (void *)malloc(count) ; record_allocation[max_allocation++] = new; return new; } static int start_interesting ; void mallocd_start() { start_interesting = max_allocation ; } void mallocd_junk() {} void mallocd_print() { int ii ; printf("malloc max %d start %d\n", max_allocation , start_interesting) ; printf("malloc max %x start %x\n", 4 * max_allocation ,4 * start_interesting) ; for(ii = start_interesting; ii< max_allocation ; ii++) { if (record_allocation[ii] != NULL) printf("offset %x , address %x\n", 4 * ii, record_allocation[ii]) ; } mallocd_junk() ; }