diff options
Diffstat (limited to 'mem')
-rw-r--r-- | mem/include/mem.h | 24 |
1 files changed, 13 insertions, 11 deletions
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 @@ | |||
92 | /// The caller can use 'i' as the index of the current chunk. | 92 | /// The caller can use 'i' as the index of the current chunk. |
93 | /// | 93 | /// |
94 | /// It is valid to mem_free() the chunk at each step of the iteration. | 94 | /// It is valid to mem_free() the chunk at each step of the iteration. |
95 | #define mem_foreach(MEM, ITER, BODY) \ | 95 | #define mem_foreach(MEM, ITER, BODY) \ |
96 | size_t i = 0; \ | 96 | { \ |
97 | do { \ | 97 | size_t i = 0; \ |
98 | if ((MEM)->mem.chunks[i].used) { \ | 98 | do { \ |
99 | __typeof__((MEM)->object[0])* ITER = \ | 99 | if ((MEM)->mem.chunks[i].used) { \ |
100 | &(((__typeof__((MEM)->object[0])*)(MEM)->mem.blocks))[i]; \ | 100 | __typeof__((MEM)->object[0])* ITER = \ |
101 | (void)ITER; \ | 101 | &(((__typeof__((MEM)->object[0])*)(MEM)->mem.blocks))[i]; \ |
102 | BODY; \ | 102 | (void)ITER; \ |
103 | } \ | 103 | BODY; \ |
104 | i = (MEM)->chunks[i].next; \ | 104 | } \ |
105 | } while (i); | 105 | i = (MEM)->mem.chunks[i].next; \ |
106 | } while (i); \ | ||
107 | } | ||
106 | 108 | ||
107 | // ----------------------------------------------------------------------------- | 109 | // ----------------------------------------------------------------------------- |
108 | 110 | ||