mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-05-04 11:01:26 +03:00
Reformat the codebase with the clang-format 18.
This commit is contained in:
parent
0a6215c171
commit
f1bba4a87c
346 changed files with 18286 additions and 17770 deletions
177
test/unit/hook.c
177
test/unit/hook.c
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
#include "jemalloc/internal/hook.h"
|
||||
|
||||
static void *arg_extra;
|
||||
static int arg_type;
|
||||
static void *arg_result;
|
||||
static void *arg_address;
|
||||
static size_t arg_old_usize;
|
||||
static size_t arg_new_usize;
|
||||
static void *arg_extra;
|
||||
static int arg_type;
|
||||
static void *arg_result;
|
||||
static void *arg_address;
|
||||
static size_t arg_old_usize;
|
||||
static size_t arg_new_usize;
|
||||
static uintptr_t arg_result_raw;
|
||||
static uintptr_t arg_args_raw[4];
|
||||
|
||||
|
|
@ -71,8 +71,8 @@ set_args_raw(uintptr_t *args_raw, int nargs) {
|
|||
|
||||
static void
|
||||
expect_args_raw(uintptr_t *args_raw_expected, int nargs) {
|
||||
int cmp = memcmp(args_raw_expected, arg_args_raw,
|
||||
sizeof(uintptr_t) * nargs);
|
||||
int cmp = memcmp(
|
||||
args_raw_expected, arg_args_raw, sizeof(uintptr_t) * nargs);
|
||||
expect_d_eq(cmp, 0, "Raw args mismatch");
|
||||
}
|
||||
|
||||
|
|
@ -95,8 +95,8 @@ test_alloc_hook(void *extra, hook_alloc_t type, void *result,
|
|||
}
|
||||
|
||||
static void
|
||||
test_dalloc_hook(void *extra, hook_dalloc_t type, void *address,
|
||||
uintptr_t args_raw[3]) {
|
||||
test_dalloc_hook(
|
||||
void *extra, hook_dalloc_t type, void *address, uintptr_t args_raw[3]) {
|
||||
call_count++;
|
||||
arg_extra = extra;
|
||||
arg_type = (int)type;
|
||||
|
|
@ -122,16 +122,15 @@ test_expand_hook(void *extra, hook_expand_t type, void *address,
|
|||
|
||||
TEST_BEGIN(test_hooks_basic) {
|
||||
/* Just verify that the record their arguments correctly. */
|
||||
hooks_t hooks = {
|
||||
&test_alloc_hook, &test_dalloc_hook, &test_expand_hook,
|
||||
(void *)111};
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
hooks_t hooks = {&test_alloc_hook, &test_dalloc_hook, &test_expand_hook,
|
||||
(void *)111};
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
uintptr_t args_raw[4] = {10, 20, 30, 40};
|
||||
|
||||
/* Alloc */
|
||||
reset_args();
|
||||
hook_invoke_alloc(hook_alloc_posix_memalign, (void *)222, 333,
|
||||
args_raw);
|
||||
hook_invoke_alloc(
|
||||
hook_alloc_posix_memalign, (void *)222, 333, args_raw);
|
||||
expect_ptr_eq(arg_extra, (void *)111, "Passed wrong user pointer");
|
||||
expect_d_eq((int)hook_alloc_posix_memalign, arg_type,
|
||||
"Passed wrong alloc type");
|
||||
|
|
@ -142,18 +141,18 @@ TEST_BEGIN(test_hooks_basic) {
|
|||
/* Dalloc */
|
||||
reset_args();
|
||||
hook_invoke_dalloc(hook_dalloc_sdallocx, (void *)222, args_raw);
|
||||
expect_d_eq((int)hook_dalloc_sdallocx, arg_type,
|
||||
"Passed wrong dalloc type");
|
||||
expect_d_eq(
|
||||
(int)hook_dalloc_sdallocx, arg_type, "Passed wrong dalloc type");
|
||||
expect_ptr_eq((void *)111, arg_extra, "Passed wrong user pointer");
|
||||
expect_ptr_eq((void *)222, arg_address, "Passed wrong address");
|
||||
expect_args_raw(args_raw, 3);
|
||||
|
||||
/* Expand */
|
||||
reset_args();
|
||||
hook_invoke_expand(hook_expand_xallocx, (void *)222, 333, 444, 555,
|
||||
args_raw);
|
||||
expect_d_eq((int)hook_expand_xallocx, arg_type,
|
||||
"Passed wrong expand type");
|
||||
hook_invoke_expand(
|
||||
hook_expand_xallocx, (void *)222, 333, 444, 555, args_raw);
|
||||
expect_d_eq(
|
||||
(int)hook_expand_xallocx, arg_type, "Passed wrong expand type");
|
||||
expect_ptr_eq((void *)111, arg_extra, "Passed wrong user pointer");
|
||||
expect_ptr_eq((void *)222, arg_address, "Passed wrong address");
|
||||
expect_zu_eq(333, arg_old_usize, "Passed wrong old usize");
|
||||
|
|
@ -205,7 +204,7 @@ TEST_END
|
|||
|
||||
TEST_BEGIN(test_hooks_remove) {
|
||||
hooks_t hooks = {&test_alloc_hook, NULL, NULL, NULL};
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
expect_ptr_ne(handle, NULL, "Hook installation failed");
|
||||
call_count = 0;
|
||||
uintptr_t args_raw[4] = {10, 20, 30, 40};
|
||||
|
|
@ -216,14 +215,13 @@ TEST_BEGIN(test_hooks_remove) {
|
|||
hook_remove(TSDN_NULL, handle);
|
||||
hook_invoke_alloc(hook_alloc_malloc, NULL, 0, NULL);
|
||||
expect_d_eq(call_count, 0, "Hook invoked after removal");
|
||||
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_hooks_alloc_simple) {
|
||||
/* "Simple" in the sense that we're not in a realloc variant. */
|
||||
hooks_t hooks = {&test_alloc_hook, NULL, NULL, (void *)123};
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
expect_ptr_ne(handle, NULL, "Hook installation failed");
|
||||
|
||||
/* Stop malloc from being optimized away. */
|
||||
|
|
@ -237,8 +235,8 @@ TEST_BEGIN(test_hooks_alloc_simple) {
|
|||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_d_eq(arg_type, (int)hook_alloc_malloc, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_result, "Wrong result");
|
||||
expect_u64_eq((uintptr_t)ptr, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)1, arg_args_raw[0], "Wrong argument");
|
||||
free(ptr);
|
||||
|
||||
|
|
@ -247,11 +245,11 @@ TEST_BEGIN(test_hooks_alloc_simple) {
|
|||
err = posix_memalign((void **)&ptr, 1024, 1);
|
||||
expect_d_eq(call_count, 1, "Hook not called");
|
||||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_d_eq(arg_type, (int)hook_alloc_posix_memalign,
|
||||
"Wrong hook type");
|
||||
expect_d_eq(
|
||||
arg_type, (int)hook_alloc_posix_memalign, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_result, "Wrong result");
|
||||
expect_u64_eq((uintptr_t)err, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)err, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)&ptr, arg_args_raw[0], "Wrong argument");
|
||||
expect_u64_eq((uintptr_t)1024, arg_args_raw[1], "Wrong argument");
|
||||
expect_u64_eq((uintptr_t)1, arg_args_raw[2], "Wrong argument");
|
||||
|
|
@ -262,11 +260,10 @@ TEST_BEGIN(test_hooks_alloc_simple) {
|
|||
ptr = aligned_alloc(1024, 1);
|
||||
expect_d_eq(call_count, 1, "Hook not called");
|
||||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_d_eq(arg_type, (int)hook_alloc_aligned_alloc,
|
||||
"Wrong hook type");
|
||||
expect_d_eq(arg_type, (int)hook_alloc_aligned_alloc, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_result, "Wrong result");
|
||||
expect_u64_eq((uintptr_t)ptr, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)1024, arg_args_raw[0], "Wrong argument");
|
||||
expect_u64_eq((uintptr_t)1, arg_args_raw[1], "Wrong argument");
|
||||
free(ptr);
|
||||
|
|
@ -278,8 +275,8 @@ TEST_BEGIN(test_hooks_alloc_simple) {
|
|||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_d_eq(arg_type, (int)hook_alloc_calloc, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_result, "Wrong result");
|
||||
expect_u64_eq((uintptr_t)ptr, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)11, arg_args_raw[0], "Wrong argument");
|
||||
expect_u64_eq((uintptr_t)13, arg_args_raw[1], "Wrong argument");
|
||||
free(ptr);
|
||||
|
|
@ -292,8 +289,8 @@ TEST_BEGIN(test_hooks_alloc_simple) {
|
|||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_d_eq(arg_type, (int)hook_alloc_memalign, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_result, "Wrong result");
|
||||
expect_u64_eq((uintptr_t)ptr, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)1024, arg_args_raw[0], "Wrong argument");
|
||||
expect_u64_eq((uintptr_t)1, arg_args_raw[1], "Wrong argument");
|
||||
free(ptr);
|
||||
|
|
@ -307,8 +304,8 @@ TEST_BEGIN(test_hooks_alloc_simple) {
|
|||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_d_eq(arg_type, (int)hook_alloc_valloc, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_result, "Wrong result");
|
||||
expect_u64_eq((uintptr_t)ptr, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)1, arg_args_raw[0], "Wrong argument");
|
||||
free(ptr);
|
||||
#endif /* JEMALLOC_OVERRIDE_VALLOC */
|
||||
|
|
@ -321,8 +318,8 @@ TEST_BEGIN(test_hooks_alloc_simple) {
|
|||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_d_eq(arg_type, (int)hook_alloc_pvalloc, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_result, "Wrong result");
|
||||
expect_u64_eq((uintptr_t)ptr, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)1, arg_args_raw[0], "Wrong argument");
|
||||
free(ptr);
|
||||
#endif /* JEMALLOC_OVERRIDE_PVALLOC */
|
||||
|
|
@ -334,11 +331,11 @@ TEST_BEGIN(test_hooks_alloc_simple) {
|
|||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_d_eq(arg_type, (int)hook_alloc_mallocx, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_result, "Wrong result");
|
||||
expect_u64_eq((uintptr_t)ptr, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)1, arg_args_raw[0], "Wrong argument");
|
||||
expect_u64_eq((uintptr_t)MALLOCX_LG_ALIGN(10), arg_args_raw[1],
|
||||
"Wrong flags");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)MALLOCX_LG_ALIGN(10), arg_args_raw[1], "Wrong flags");
|
||||
free(ptr);
|
||||
|
||||
hook_remove(TSDN_NULL, handle);
|
||||
|
|
@ -348,7 +345,7 @@ TEST_END
|
|||
TEST_BEGIN(test_hooks_dalloc_simple) {
|
||||
/* "Simple" in the sense that we're not in a realloc variant. */
|
||||
hooks_t hooks = {NULL, &test_dalloc_hook, NULL, (void *)123};
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
expect_ptr_ne(handle, NULL, "Hook installation failed");
|
||||
|
||||
void *volatile ptr;
|
||||
|
|
@ -372,8 +369,8 @@ TEST_BEGIN(test_hooks_dalloc_simple) {
|
|||
expect_d_eq(arg_type, (int)hook_dalloc_dallocx, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_address, "Wrong pointer freed");
|
||||
expect_u64_eq((uintptr_t)ptr, arg_args_raw[0], "Wrong raw arg");
|
||||
expect_u64_eq((uintptr_t)MALLOCX_TCACHE_NONE, arg_args_raw[1],
|
||||
"Wrong raw arg");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)MALLOCX_TCACHE_NONE, arg_args_raw[1], "Wrong raw arg");
|
||||
|
||||
/* sdallocx() */
|
||||
reset();
|
||||
|
|
@ -385,8 +382,8 @@ TEST_BEGIN(test_hooks_dalloc_simple) {
|
|||
expect_ptr_eq(ptr, arg_address, "Wrong pointer freed");
|
||||
expect_u64_eq((uintptr_t)ptr, arg_args_raw[0], "Wrong raw arg");
|
||||
expect_u64_eq((uintptr_t)1, arg_args_raw[1], "Wrong raw arg");
|
||||
expect_u64_eq((uintptr_t)MALLOCX_TCACHE_NONE, arg_args_raw[2],
|
||||
"Wrong raw arg");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)MALLOCX_TCACHE_NONE, arg_args_raw[2], "Wrong raw arg");
|
||||
|
||||
hook_remove(TSDN_NULL, handle);
|
||||
}
|
||||
|
|
@ -395,7 +392,7 @@ TEST_END
|
|||
TEST_BEGIN(test_hooks_expand_simple) {
|
||||
/* "Simple" in the sense that we're not in a realloc variant. */
|
||||
hooks_t hooks = {NULL, NULL, &test_expand_hook, (void *)123};
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
expect_ptr_ne(handle, NULL, "Hook installation failed");
|
||||
|
||||
void *volatile ptr;
|
||||
|
|
@ -421,9 +418,9 @@ TEST_BEGIN(test_hooks_expand_simple) {
|
|||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_hooks_realloc_as_malloc_or_free) {
|
||||
hooks_t hooks = {&test_alloc_hook, &test_dalloc_hook,
|
||||
&test_expand_hook, (void *)123};
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
hooks_t hooks = {&test_alloc_hook, &test_dalloc_hook, &test_expand_hook,
|
||||
(void *)123};
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
expect_ptr_ne(handle, NULL, "Hook installation failed");
|
||||
|
||||
void *volatile ptr;
|
||||
|
|
@ -435,8 +432,8 @@ TEST_BEGIN(test_hooks_realloc_as_malloc_or_free) {
|
|||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_d_eq(arg_type, (int)hook_alloc_realloc, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_result, "Wrong result");
|
||||
expect_u64_eq((uintptr_t)ptr, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)NULL, arg_args_raw[0], "Wrong argument");
|
||||
expect_u64_eq((uintptr_t)1, arg_args_raw[1], "Wrong argument");
|
||||
free(ptr);
|
||||
|
|
@ -448,14 +445,11 @@ TEST_BEGIN(test_hooks_realloc_as_malloc_or_free) {
|
|||
realloc(ptr, 0);
|
||||
expect_d_eq(call_count, 1, "Hook not called");
|
||||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_d_eq(arg_type, (int)hook_dalloc_realloc,
|
||||
"Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_address,
|
||||
"Wrong pointer freed");
|
||||
expect_u64_eq((uintptr_t)ptr, arg_args_raw[0],
|
||||
"Wrong raw arg");
|
||||
expect_u64_eq((uintptr_t)0, arg_args_raw[1],
|
||||
"Wrong raw arg");
|
||||
expect_d_eq(
|
||||
arg_type, (int)hook_dalloc_realloc, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_address, "Wrong pointer freed");
|
||||
expect_u64_eq((uintptr_t)ptr, arg_args_raw[0], "Wrong raw arg");
|
||||
expect_u64_eq((uintptr_t)0, arg_args_raw[1], "Wrong raw arg");
|
||||
}
|
||||
|
||||
/* realloc(NULL, 0) as malloc(0) */
|
||||
|
|
@ -465,8 +459,8 @@ TEST_BEGIN(test_hooks_realloc_as_malloc_or_free) {
|
|||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_d_eq(arg_type, (int)hook_alloc_realloc, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_result, "Wrong result");
|
||||
expect_u64_eq((uintptr_t)ptr, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)NULL, arg_args_raw[0], "Wrong argument");
|
||||
expect_u64_eq((uintptr_t)0, arg_args_raw[1], "Wrong argument");
|
||||
free(ptr);
|
||||
|
|
@ -478,9 +472,9 @@ TEST_END
|
|||
static void
|
||||
do_realloc_test(void *(*ralloc)(void *, size_t, int), int flags,
|
||||
int expand_type, int dalloc_type) {
|
||||
hooks_t hooks = {&test_alloc_hook, &test_dalloc_hook,
|
||||
&test_expand_hook, (void *)123};
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
hooks_t hooks = {&test_alloc_hook, &test_dalloc_hook, &test_expand_hook,
|
||||
(void *)123};
|
||||
void *handle = hook_install(TSDN_NULL, &hooks);
|
||||
expect_ptr_ne(handle, NULL, "Hook installation failed");
|
||||
|
||||
void *volatile ptr;
|
||||
|
|
@ -496,8 +490,8 @@ do_realloc_test(void *(*ralloc)(void *, size_t, int), int flags,
|
|||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_d_eq(arg_type, expand_type, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_address, "Wrong address");
|
||||
expect_u64_eq((uintptr_t)ptr, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)ptr, arg_args_raw[0], "Wrong argument");
|
||||
expect_u64_eq((uintptr_t)130, arg_args_raw[1], "Wrong argument");
|
||||
free(ptr);
|
||||
|
|
@ -522,11 +516,11 @@ do_realloc_test(void *(*ralloc)(void *, size_t, int), int flags,
|
|||
}
|
||||
expect_ptr_eq(arg_extra, (void *)123, "Wrong extra");
|
||||
expect_ptr_eq(ptr2, arg_address, "Wrong address");
|
||||
expect_u64_eq((uintptr_t)ptr, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)ptr2, arg_args_raw[0], "Wrong argument");
|
||||
expect_u64_eq((uintptr_t)2 * 1024 * 1024, arg_args_raw[1],
|
||||
"Wrong argument");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)2 * 1024 * 1024, arg_args_raw[1], "Wrong argument");
|
||||
free(ptr);
|
||||
|
||||
/* Realloc with move, small. */
|
||||
|
|
@ -540,8 +534,8 @@ do_realloc_test(void *(*ralloc)(void *, size_t, int), int flags,
|
|||
expect_d_eq(arg_type, dalloc_type, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_address, "Wrong address");
|
||||
expect_ptr_eq(ptr2, arg_result, "Wrong address");
|
||||
expect_u64_eq((uintptr_t)ptr2, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr2, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)ptr, arg_args_raw[0], "Wrong argument");
|
||||
expect_u64_eq((uintptr_t)128, arg_args_raw[1], "Wrong argument");
|
||||
free(ptr2);
|
||||
|
|
@ -557,11 +551,11 @@ do_realloc_test(void *(*ralloc)(void *, size_t, int), int flags,
|
|||
expect_d_eq(arg_type, dalloc_type, "Wrong hook type");
|
||||
expect_ptr_eq(ptr, arg_address, "Wrong address");
|
||||
expect_ptr_eq(ptr2, arg_result, "Wrong address");
|
||||
expect_u64_eq((uintptr_t)ptr2, (uintptr_t)arg_result_raw,
|
||||
"Wrong raw result");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)ptr2, (uintptr_t)arg_result_raw, "Wrong raw result");
|
||||
expect_u64_eq((uintptr_t)ptr, arg_args_raw[0], "Wrong argument");
|
||||
expect_u64_eq((uintptr_t)2 * 1024 * 1024, arg_args_raw[1],
|
||||
"Wrong argument");
|
||||
expect_u64_eq(
|
||||
(uintptr_t)2 * 1024 * 1024, arg_args_raw[1], "Wrong argument");
|
||||
free(ptr2);
|
||||
|
||||
hook_remove(TSDN_NULL, handle);
|
||||
|
|
@ -573,8 +567,8 @@ realloc_wrapper(void *ptr, size_t size, UNUSED int flags) {
|
|||
}
|
||||
|
||||
TEST_BEGIN(test_hooks_realloc) {
|
||||
do_realloc_test(&realloc_wrapper, 0, hook_expand_realloc,
|
||||
hook_dalloc_realloc);
|
||||
do_realloc_test(
|
||||
&realloc_wrapper, 0, hook_expand_realloc, hook_dalloc_realloc);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
|
|
@ -587,14 +581,9 @@ TEST_END
|
|||
int
|
||||
main(void) {
|
||||
/* We assert on call counts. */
|
||||
return test_no_reentrancy(
|
||||
test_hooks_basic,
|
||||
test_hooks_null,
|
||||
test_hooks_remove,
|
||||
test_hooks_alloc_simple,
|
||||
test_hooks_dalloc_simple,
|
||||
test_hooks_expand_simple,
|
||||
test_hooks_realloc_as_malloc_or_free,
|
||||
test_hooks_realloc,
|
||||
return test_no_reentrancy(test_hooks_basic, test_hooks_null,
|
||||
test_hooks_remove, test_hooks_alloc_simple,
|
||||
test_hooks_dalloc_simple, test_hooks_expand_simple,
|
||||
test_hooks_realloc_as_malloc_or_free, test_hooks_realloc,
|
||||
test_hooks_rallocx);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue