thesis: Complete 2.2
This commit is contained in:
15
thesis/listings/preload.c
Normal file
15
thesis/listings/preload.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user