ust: mallocwrap: add
[ust.git] / libmallocwrap / mallocwrap.c
1 #define _GNU_SOURCE
2 #include <dlfcn.h>
3 #include <sys/types.h>
4 #include <stdio.h>
5
6 void *(*plibc_malloc)(size_t size) = NULL;
7
8 void *malloc(size_t size)
9 {
10 if(plibc_malloc == NULL) {
11 plibc_malloc = dlsym(RTLD_NEXT, "malloc");
12 if(plibc_malloc == NULL) {
13 fprintf(stderr, "mallocwrap: unable to find malloc\n");
14 return NULL;
15 }
16 }
17 fprintf(stderr, "mallocating size %d\n", size);
18 return plibc_malloc(size);
19 }
This page took 0.031179 seconds and 5 git commands to generate.