i'm trying to use a little bit of code to log mallocs in tcpdump for a project of mine, the code i'm using is thus:
#include <stdlib.h>
unsigned int memCount = 0;
void *my_malloc(size_t size) {
void *p = malloc(size);
memCount = memCount + size;
printf("Memory Allocated :%u \n", size
return p;
}
#define malloc(size) my_malloc(size)
After looking at many similar questions online it seems that this should work, however my custom malloc does not seem to be getting called. Any help would be much appreciated, thanks!