Skip to content

Commit

Permalink
Added cleanup to test
Browse files Browse the repository at this point in the history
  • Loading branch information
Milovidov Mikhail committed Apr 9, 2020
1 parent 39f9fb1 commit 99ea9e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 6 additions & 0 deletions test/test-stress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 99ea9e6

Please sign in to comment.