diff options
author | David Robillard <d@drobilla.net> | 2020-12-31 15:15:05 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-12-31 15:21:29 +0100 |
commit | 741c3349b09c8774fcd013e3bdd7d9e7f6b470ce (patch) | |
tree | a941f6567b85255570e5492f3c66a842704ba9f7 /test/test_malloc.c | |
parent | 841c766d86dc35ab37c4fef8ec866d06c41bc383 (diff) | |
download | zix-741c3349b09c8774fcd013e3bdd7d9e7f6b470ce.tar.gz zix-741c3349b09c8774fcd013e3bdd7d9e7f6b470ce.tar.bz2 zix-741c3349b09c8774fcd013e3bdd7d9e7f6b470ce.zip |
Format all code with clang-format
Diffstat (limited to 'test/test_malloc.c')
-rw-r--r-- | test/test_malloc.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/test/test_malloc.c b/test/test_malloc.c index 1138502..971d583 100644 --- a/test/test_malloc.c +++ b/test/test_malloc.c @@ -15,7 +15,7 @@ */ #ifndef __APPLE__ -#define _GNU_SOURCE +# define _GNU_SOURCE #endif #include "test_malloc.h" @@ -34,64 +34,64 @@ static volatile bool in_test_malloc_init = false; static void* test_malloc(size_t size) { - if (in_test_malloc_init) { - return NULL; // dlsym is asking for memory, but handles this fine - } + if (in_test_malloc_init) { + return NULL; // dlsym is asking for memory, but handles this fine + } - if (!test_malloc_sys_malloc) { - test_malloc_init(); - } + if (!test_malloc_sys_malloc) { + test_malloc_init(); + } - if (test_malloc_n_allocs < test_malloc_fail_after) { - ++test_malloc_n_allocs; - return test_malloc_sys_malloc(size); - } + if (test_malloc_n_allocs < test_malloc_fail_after) { + ++test_malloc_n_allocs; + return test_malloc_sys_malloc(size); + } - return NULL; + return NULL; } void* malloc(size_t size) { - return test_malloc(size); + return test_malloc(size); } void* calloc(size_t nmemb, size_t size) { - void* ptr = test_malloc(nmemb * size); - if (ptr) { - memset(ptr, 0, nmemb * size); - } - return ptr; + void* ptr = test_malloc(nmemb * size); + if (ptr) { + memset(ptr, 0, nmemb * size); + } + return ptr; } void test_malloc_reset(size_t fail_after) { - test_malloc_fail_after = fail_after; - test_malloc_n_allocs = 0; + test_malloc_fail_after = fail_after; + test_malloc_n_allocs = 0; } void test_malloc_init(void) { - in_test_malloc_init = true; + in_test_malloc_init = true; - /* Avoid pedantic warnings about casting pointer to function pointer by - casting dlsym instead. */ + /* Avoid pedantic warnings about casting pointer to function pointer by + casting dlsym instead. */ - typedef void* (*MallocFunc)(size_t); - typedef MallocFunc (*MallocFuncGetter)(void*, const char*); + typedef void* (*MallocFunc)(size_t); + typedef MallocFunc (*MallocFuncGetter)(void*, const char*); - MallocFuncGetter dlfunc = (MallocFuncGetter)dlsym; - test_malloc_sys_malloc = (MallocFunc)dlfunc(RTLD_NEXT, "malloc"); + MallocFuncGetter dlfunc = (MallocFuncGetter)dlsym; + test_malloc_sys_malloc = (MallocFunc)dlfunc(RTLD_NEXT, "malloc"); - in_test_malloc_init = false; + in_test_malloc_init = false; } size_t test_malloc_get_n_allocs(void) { - return test_malloc_n_allocs; + return test_malloc_n_allocs; } |