From 99ea9e6c6080dab2c8065ffe425c97c6b0ccbb63 Mon Sep 17 00:00:00 2001 From: Milovidov Mikhail Date: Thu, 9 Apr 2020 17:20:13 +0300 Subject: [PATCH] Added cleanup to test --- CMakeLists.txt | 2 +- test/test-stress.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fda7a60..c3d0a0ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ option(MI_INTERPOSE "Use interpose to override standard malloc on macOS" option(MI_OSX_ZONE "Use malloc zone to override standard malloc on macOS" OFF) # enables interpose as well option(MI_LOCAL_DYNAMIC_TLS "Use slightly slower, dlopen-compatible TLS mechanism (Unix)" OFF) option(MI_BUILD_TESTS "Build test executables" ON) -option(MI_USER_CLEANUP "Enable user defined functionality for custom memory clean function" OFF) +option(MI_USER_CLEANUP "Enable user defined functionality for custom memory clean function" ON) option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF) option(MI_PADDING "Enable padding to detect heap block overflow (only in debug mode)" ON) diff --git a/test/test-stress.c b/test/test-stress.c index 7d8993a0..3fbf4d4d 100644 --- a/test/test-stress.c +++ b/test/test-stress.c @@ -63,6 +63,11 @@ static void* atomic_exchange_ptr(volatile void** p, void* newval); typedef uintptr_t* random_t; +void memory_cleanup(void* user_data, void* ptr, size_t size) { + (void)user_data; + memset(ptr, 0, size); +} + static uintptr_t pick(random_t r) { uintptr_t x = *r; #if (UINTPTR_MAX > UINT32_MAX) @@ -218,6 +223,7 @@ static void test_leak(void) { #endif int main(int argc, char** argv) { + mi_register_user_cleanup(memory_cleanup, NULL); // > mimalloc-test-stress [THREADS] [SCALE] [ITER] if (argc >= 2) { char* end;