From cd8df67f20c1759e58cd1b27c10ad9876c554bfe Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Tue, 19 Aug 2014 22:43:46 -0400 Subject: [PATCH] Update mem module to count allocations and deletions for a lightweight form of leak detection --- source/mem/mem.c | 2 ++ tests/test_list.c | 1 + 2 files changed, 3 insertions(+) diff --git a/source/mem/mem.c b/source/mem/mem.c index 81b9b2d..643219b 100644 --- a/source/mem/mem.c +++ b/source/mem/mem.c @@ -158,6 +158,8 @@ void mem_release(void* p_obj) { #if (LEAK_DETECT_LEVEL == 2) deregister_block(p_obj); + #elif (LEAK_DETECT_LEVEL == 1) + Num_Allocations--; #endif if(p_hdr->p_finalize) { diff --git a/tests/test_list.c b/tests/test_list.c index cd61a72..5965223 100644 --- a/tests/test_list.c +++ b/tests/test_list.c @@ -20,6 +20,7 @@ TEST_SUITE(List) { CHECK( NULL != list ); CHECK( NULL == list->head ); CHECK( NULL == list->tail ); + mem_release( list ); } //------------------------------------------------------------------------- -- 2.54.0