From ced89ff7989fde2f3d1828c9be70600d70d72e3d Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Mon, 17 Jul 2023 09:06:14 -0700 Subject: Add used list to mempool; fix mem iteration. --- mem/include/mem.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'mem') diff --git a/mem/include/mem.h b/mem/include/mem.h index b3d9157..bcff39f 100644 --- a/mem/include/mem.h +++ b/mem/include/mem.h @@ -92,17 +92,19 @@ /// The caller can use 'i' as the index of the current chunk. /// /// It is valid to mem_free() the chunk at each step of the iteration. -#define mem_foreach(MEM, ITER, BODY) \ - size_t i = 0; \ - do { \ - if ((MEM)->mem.chunks[i].used) { \ - __typeof__((MEM)->object[0])* ITER = \ - &(((__typeof__((MEM)->object[0])*)(MEM)->mem.blocks))[i]; \ - (void)ITER; \ - BODY; \ - } \ - i = (MEM)->chunks[i].next; \ - } while (i); +#define mem_foreach(MEM, ITER, BODY) \ + { \ + size_t i = 0; \ + do { \ + if ((MEM)->mem.chunks[i].used) { \ + __typeof__((MEM)->object[0])* ITER = \ + &(((__typeof__((MEM)->object[0])*)(MEM)->mem.blocks))[i]; \ + (void)ITER; \ + BODY; \ + } \ + i = (MEM)->mem.chunks[i].next; \ + } while (i); \ + } // ----------------------------------------------------------------------------- -- cgit v1.2.3