aboutsummaryrefslogtreecommitdiffstats
path: root/lib/includes/hicn/util/pool.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/includes/hicn/util/pool.h')
-rw-r--r--lib/includes/hicn/util/pool.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/includes/hicn/util/pool.h b/lib/includes/hicn/util/pool.h
index 7488e08fd..b8acadc44 100644
--- a/lib/includes/hicn/util/pool.h
+++ b/lib/includes/hicn/util/pool.h
@@ -234,6 +234,26 @@ bool _pool_validate_id (void **pool_ptr, off_t id);
} \
while (0)
+#define pool_enumerate_typed(pool, i, TYPE, ELTP, BODY) \
+ do \
+ { \
+ pool_hdr_t *_pool_var (ph) = pool_hdr (pool); \
+ bitmap_t *_pool_var (fb) = _pool_var (ph)->free_bitmap; \
+ TYPE ELTP = NULL; \
+ for ((i) = 0; (i) < _pool_var (ph)->alloc_size; (i)++) \
+ { \
+ if (bitmap_is_set (_pool_var (fb), (i))) \
+ continue; \
+ ELTP = (pool) + (i); \
+ do \
+ { \
+ BODY; \
+ } \
+ while (0); \
+ } \
+ } \
+ while (0)
+
/**
* @brief Iterate over elements in a pool.
*
@@ -256,6 +276,14 @@ bool _pool_validate_id (void **pool_ptr, off_t id);
#define pool_get_alloc_size(pool) pool_hdr (pool)->alloc_size
+#define pool_foreach_typed(pool, TYPE, ELTP, BODY) \
+ do \
+ { \
+ unsigned _pool_var (i); \
+ pool_enumerate_typed ((pool), _pool_var (i), TYPE, ELTP, BODY); \
+ } \
+ while (0)
+
#ifdef WITH_TESTS
#define pool_get_free_indices(pool) pool_hdr (pool)->free_indices
#define pool_get_free_bitmap(pool) pool_hdr (pool)->free_bitmap