summaryrefslogtreecommitdiff
path: root/wrap.c
diff options
context:
space:
mode:
Diffstat (limited to 'wrap.c')
-rw-r--r--wrap.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/wrap.c b/wrap.c
new file mode 100644
index 0000000..5ed0bc8
--- /dev/null
+++ b/wrap.c
@@ -0,0 +1,19 @@
+#include <stddef.h>
+
+#include "wrap.h"
+
+void *(*_REAL(malloc))(size_t size) = NULL;
+void (*_REAL(free))(void *ptr) = NULL;
+void *(*_REAL(calloc))(size_t nmemb, size_t size) = NULL;
+void *(*_REAL(realloc))(void *ptr, size_t size) = NULL;
+
+#ifdef __GNUC__
+void __attribute__((constructor)) __wrap_init()
+{
+ // set the real values up as soon as possible
+ REAL(malloc);
+ REAL(free);
+ REAL(calloc);
+ REAL(realloc);
+}
+#endif