mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-31 22:25:25 -04:00
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>
This commit is contained in:
parent
16b4c87470
commit
61e9196f56
1 changed files with 11 additions and 1 deletions
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue