/* These "wrappers" add logging code to both
malloc() and free(). DEBUG must be defined
before this file is #included, or the wrappers
will be ignored
The HWRAPPER definitions
protect against unintentional duplicate inclusions.
*/
#ifndef HWRAPPER
#ifdef DEBUG
#define HWRAPPER
int count;
FILE * log;
void my_free(void * tree)
{
if (log == NULL) log = fopen("log","w");
fprintf(log,"%p 99999 free\n",tree);
free(tree);
}
void * my_alloc(size_t size)
{
void * temp;
if (log == NULL) log = fopen("log","w");
temp = (void *) malloc(size);
fprintf(log,"%p %5.5d anew\n",temp,count++);
return temp;
}
#define malloc(x) my_alloc(x)
#define free(x) my_free(x)
#endif
#endif
/* End of File */