vppinfra: add pool_foreach_pointer()
Works on pools of pointers... Type: improvement Change-Id: I194dec389ca4c5ec2ce3361b54a9968c9caecefc Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:
Damjan Marion
committed by
Florin Coras
parent
39a8e16448
commit
91ff0e965a
@ -13,6 +13,7 @@ ForEachMacros:
|
||||
- 'clib_bitmap_foreach'
|
||||
- 'pool_foreach'
|
||||
- 'pool_foreach_index'
|
||||
- 'pool_foreach_pointer'
|
||||
- 'vec_foreach'
|
||||
- 'vec_foreach_backwards'
|
||||
- 'vec_foreach_index'
|
||||
|
@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user