Commit | Line | Data |
---|---|---|
e541a28d PMF |
1 | #define _GNU_SOURCE |
2 | #include <dlfcn.h> | |
3 | #include <sys/types.h> | |
4 | #include <stdio.h> | |
5 | ||
fbd8191b PMF |
6 | #include "marker.h" |
7 | ||
e541a28d PMF |
8 | void *(*plibc_malloc)(size_t size) = NULL; |
9 | ||
10 | void *malloc(size_t size) | |
11 | { | |
12 | if(plibc_malloc == NULL) { | |
13 | plibc_malloc = dlsym(RTLD_NEXT, "malloc"); | |
14 | if(plibc_malloc == NULL) { | |
15 | fprintf(stderr, "mallocwrap: unable to find malloc\n"); | |
16 | return NULL; | |
17 | } | |
18 | } | |
fbd8191b PMF |
19 | |
20 | trace_mark(ust, malloc, "%d", (int)size); | |
21 | ||
e541a28d PMF |
22 | fprintf(stderr, "mallocating size %d\n", size); |
23 | return plibc_malloc(size); | |
24 | } | |
fbd8191b PMF |
25 | |
26 | MARKER_LIB |