Skip to content

Instantly share code, notes, and snippets.

@dmikurube
Created January 20, 2012 06:42
Show Gist options
  • Save dmikurube/1645801 to your computer and use it in GitHub Desktop.
Save dmikurube/1645801 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
void* backed_malloc(size_t size) __attribute__ ((weak, alias ("malloc")));
void* hook_malloc(size_t size) {
printf("%ld\n", size);
return backed_malloc(size + 1);
}
void* malloc(size_t size) __attribute__ ((weak, alias ("hook_malloc")));
int main() {
char *buf = malloc(12);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment