#include #include #include void *malloc(size_t size) { // before call to malloc void *(*_malloc)(size_t); if ((_malloc = dlsym(RTLD_NEXT, "malloc")) == NULL) { errno = ENOSYS; return NULL; } void *ret = _malloc(size); // after call to malloc return ret; }