summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.clang-format1
-rw-r--r--src/vppinfra/pool.h7
2 files changed, 8 insertions, 0 deletions
diff --git a/.clang-format b/.clang-format
index a49d164f432..0680770a07f 100644
--- a/.clang-format
+++ b/.clang-format
@@ -13,6 +13,7 @@ ForEachMacros:
- 'clib_bitmap_foreach'
- 'pool_foreach'
- 'pool_foreach_index'
+ - 'pool_foreach_pointer'
- 'vec_foreach'
- 'vec_foreach_backwards'
- 'vec_foreach_index'
diff --git a/src/vppinfra/pool.h b/src/vppinfra/pool.h
index 968614e0b9d..99138386fe6 100644
--- a/src/vppinfra/pool.h
+++ b/src/vppinfra/pool.h
@@ -568,6 +568,13 @@ do { \
(s)); \
(i) < (e); (i) = pool_get_next_index ((v), (i)))
+/* works only for pool of pointers, e is declared inside macro */
+#define pool_foreach_pointer(e, p) \
+ if (p) \
+ for (typeof ((p)[0]) *_t = (p) + pool_get_first_index (p), (e) = *_t; \
+ _t < vec_end (p); \
+ _t = (p) + pool_get_next_index (p, _t - (p)), (e) = *_t)
+
/**
* @brief Remove all elements from a pool in a safe way
*