summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2023-08-02 15:58:58 +0000
committerFlorin Coras <florin.coras@gmail.com>2023-08-02 17:41:22 +0000
commit91ff0e965a442122d31fc1f52f03d0622ac564d0 (patch)
treea5da1581c6c582a9aa5397b22907f191a75c06bb /src/vppinfra
parent39a8e164486d74e1d4ded5cb83e5a5fec93db3b1 (diff)
vppinfra: add pool_foreach_pointer()
Works on pools of pointers... Type: improvement Change-Id: I194dec389ca4c5ec2ce3361b54a9968c9caecefc Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/pool.h7
1 files changed, 7 insertions, 0 deletions
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
*