diff options
author | Daniel Stone <daniel@fooishbar.org> | 2012-07-23 19:54:39 +0100 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-07-23 16:40:58 -0400 |
commit | 61e9196f565e02b1774699e865a81a4efd3904bb (patch) | |
tree | 4e88af6dce53f0918fbaafa911edbeb737e0e0e9 | |
parent | 16b4c8747053e73bb963ea2bdf566cc54b9aeb90 (diff) |
test-runner: Wrap realloc() too
So all our tests don't start failing just because we had the temerity to
use realloc() rather than malloc().
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r-- | tests/test-runner.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/test-runner.c b/tests/test-runner.c index c4a57a3..5e8ec95 100644 --- a/tests/test-runner.c +++ b/tests/test-runner.c @@ -36,6 +36,7 @@ static int num_alloc; static void* (*sys_malloc)(size_t); static void (*sys_free)(void*); +static void* (*sys_realloc)(void*, size_t); extern const struct test __start_test_section, __stop_test_section; @@ -54,6 +55,14 @@ free(void* mem) sys_free(mem); } +__attribute__ ((visibility("default"))) void * +realloc(void* mem, size_t size) +{ + if (mem == NULL) + num_alloc++; + return sys_realloc(mem, size); +} + static const struct test * find_test(const char *name) { @@ -86,7 +95,8 @@ int main(int argc, char *argv[]) int total, pass; siginfo_t info; - /* Load system malloc and free */ + /* Load system malloc, free, and realloc */ + sys_realloc = dlsym(RTLD_NEXT, "realloc"); sys_malloc = dlsym(RTLD_NEXT, "malloc"); sys_free = dlsym(RTLD_NEXT, "free"); |