Created
August 18, 2009 13:57
-
-
Save mheffner/169723 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <dlfcn.h> | |
static void *(*malloc_internal)(size_t size); | |
void __attribute__ ((constructor)) init(void); | |
/* Library constructor */ | |
void | |
init(void) | |
{ | |
malloc_internal = dlsym(RTLD_NEXT, "malloc"); | |
} | |
void * | |
malloc(size_t size) | |
{ | |
void *ret; | |
ret = malloc_internal(size); | |
printf ("Malloc request for %zd bytes got memory: %p\n", size, ret); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment