aboutsummaryrefslogtreecommitdiff
path: root/mempool/test/mempool_test.c
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-06-30 19:29:07 -0700
committer3gg <3gg@shellblade.net>2025-06-30 19:29:07 -0700
commit1fc8bb7142868bbeac5bcbbd489cd23347716203 (patch)
tree491b77b91dc4fa30d199cd56ec54c58e1d716e71 /mempool/test/mempool_test.c
parentb48f99a40b1a58c02ccbcb75bc18a158294c356f (diff)
Fix: set num used blocks to 0 on clear
Diffstat (limited to 'mempool/test/mempool_test.c')
-rw-r--r--mempool/test/mempool_test.c8
1 files changed, 5 insertions, 3 deletions
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) {
178 178
179 // Allocate chunks, contents not important. 179 // Allocate chunks, contents not important.
180 for (int i = 0; i < NUM_BLOCKS; ++i) { 180 for (int i = 0; i < NUM_BLOCKS; ++i) {
181 int* chunk = mempool_alloc(&mem); 181 const int* chunk = mempool_alloc(&mem);
182 TEST_TRUE(chunk != 0); 182 TEST_TRUE(chunk != nullptr);
183 } 183 }
184 184
185 mempool_clear(&mem); 185 mempool_clear(&mem);
186 TEST_EQUAL(mempool_size(&mem), 0);
187 TEST_EQUAL(mempool_capacity(&mem), NUM_BLOCKS);
186 188
187 // Allocate chunks and assign values 0..N. 189 // Allocate chunks and assign values 0..N.
188 for (int i = 0; i < NUM_BLOCKS; ++i) { 190 for (int i = 0; i < NUM_BLOCKS; ++i) {
189 int* chunk = mempool_alloc(&mem); 191 int* chunk = mempool_alloc(&mem);
190 TEST_TRUE(chunk != 0); 192 TEST_TRUE(chunk != nullptr);
191 *chunk = i + 1; 193 *chunk = i + 1;
192 } 194 }
193 195