ust: mallocwrap: add
[ust.git] / libmallocwrap / mallocwrap.c
CommitLineData
e541a28d
PMF
1#define _GNU_SOURCE
2#include <dlfcn.h>
3#include <sys/types.h>
4#include <stdio.h>
5
6void *(*plibc_malloc)(size_t size) = NULL;
7
8void *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.024368 seconds and 4 git commands to generate.