10 static void * (*real_malloc)(size_t) = NULL;
11 static void (*real_free)(void *ptr) = NULL;
13 static void __my_alloc_init(void)
16 real_malloc = (void *(*)(size_t))dlsym(RTLD_NEXT, "malloc");
17 real_free = (void (*)(void *))dlsym(RTLD_NEXT, "free");
18 if (real_malloc == NULL || real_free == NULL) {
19 fprintf(stderr, "Error in `dlsym`: %s\n", dlerror());
24 void *myMalloc(size_t size)
26 if (real_malloc == NULL)
29 return real_malloc(size);
32 void myFree(void *ptr)
34 if (real_free == NULL)