From 1fc8bb7142868bbeac5bcbbd489cd23347716203 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Mon, 30 Jun 2025 19:29:07 -0700 Subject: Fix: set num used blocks to 0 on clear --- mempool/test/mempool_test.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'mempool/test') diff --git a/mempool/test/mempool_test.c b/mempool/test/mempool_test.c index 843f7e7..4c55e4b 100644 --- a/mempool/test/mempool_test.c +++ b/mempool/test/mempool_test.c @@ -178,16 +178,18 @@ TEST_CASE(mem_clear_then_reuse) { // Allocate chunks, contents not important. for (int i = 0; i < NUM_BLOCKS; ++i) { - int* chunk = mempool_alloc(&mem); - TEST_TRUE(chunk != 0); + const int* chunk = mempool_alloc(&mem); + TEST_TRUE(chunk != nullptr); } mempool_clear(&mem); + TEST_EQUAL(mempool_size(&mem), 0); + TEST_EQUAL(mempool_capacity(&mem), NUM_BLOCKS); // Allocate chunks and assign values 0..N. for (int i = 0; i < NUM_BLOCKS; ++i) { int* chunk = mempool_alloc(&mem); - TEST_TRUE(chunk != 0); + TEST_TRUE(chunk != nullptr); *chunk = i + 1; } -- cgit v1.2.3