#include #include static int my_malloced=0; void *my_malloc ( int n ) { char *c=malloc(n); if (c) { my_malloced+=n; printf ( "malloced %d bytes, total %d\n", n, my_malloced ); } else { printf ( "malloced FAILED on %d bytes, total %d\n", n, my_malloced ); } return c; } void my_free ( char *c ) { free(c); printf ("free 0x%x\n", c ); }