- if (!real_malloc) {
- if (allocated_junk) {
- fprintf(stderr,
- "Panic: real malloc symbol not resolved yet, and I already gave my little private memory chunk away. "
- "Damn LD, we must extend our code to have several such areas.\n");
- exit(1);
- } else if (n > sizeof junkarea) {
- fprintf(stderr,
- "Panic: real malloc symbol not resolved yet, and I need %zu bytes while my little private memory chunk is only %zu bytes wide. "
- "Damn LD, we must fix our code to extend this area.\n", n, sizeof junkarea);
- exit(1);
- } else {
- allocated_junk = 1;
- return junkarea;
- }
- }
-#ifdef MM_LEGACY_VERBOSE
- if (!warned_raw) {
- fprintf(stderr,"Using system malloc after interception; you seem to be currently model-checking\n");
- warned_raw = 1;
- }
-#endif
- ret = real_malloc(n);
+ mm_real_realloc = (mm_realloc_t) dlsym(RTLD_NEXT, "realloc");
+ mm_real_malloc = (mm_malloc_t) dlsym(RTLD_NEXT, "malloc");
+ mm_real_free = (mm_free_t) dlsym(RTLD_NEXT, "free");
+ mm_real_calloc = (mm_calloc_t) dlsym(RTLD_NEXT, "calloc");