diff options
author | Neale Ranns <nranns@cisco.com> | 2017-02-18 08:16:41 -0800 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-03-03 17:23:50 +0000 |
commit | 87df12d5de67600414ae80b891e8a0f89e89ce5c (patch) | |
tree | 40a28e6bd9daec0c13f09dd4b8e97b4f2bebef38 /src/vppinfra/pool.h | |
parent | 4008ac998f43265451281cb6e759cd6184e50bed (diff) |
IPv6 RA improvements
1) tests for RA options
2) memleaks deleteing a ip6_radv_info_t
3) MLD prefix code refactoring
Change-Id: I34db103994bd8fbdbbec50b202d72770dd145681
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vppinfra/pool.h')
-rw-r--r-- | src/vppinfra/pool.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/vppinfra/pool.h b/src/vppinfra/pool.h index 586d13e73a9..57838e1c609 100644 --- a/src/vppinfra/pool.h +++ b/src/vppinfra/pool.h @@ -350,6 +350,7 @@ do { \ It is a bad idea to allocate or free pool element from within @c pool_foreach. Build a vector of indices and dispose of them later. + Or call pool_flush. @par Example @@ -421,6 +422,31 @@ do { \ do { body; } while (0); \ } +/** + * @brief Remove all elemenets from a pool in a safe way + * + * @param VAR each element in the pool + * @param POOL The pool to flush + * @param BODY The actions to perform on each element before it is returned to + * the pool. i.e. before it is 'freed' + */ +#define pool_flush(VAR, POOL, BODY) \ +{ \ + uword *_pool_var(ii), *_pool_var(dv) = NULL; \ + \ + pool_foreach((VAR), (POOL), \ + ({ \ + vec_add1(_pool_var(dv), (VAR) - (POOL)); \ + })); \ + vec_foreach(_pool_var(ii), _pool_var(dv)) \ + { \ + (VAR) = pool_elt_at_index((POOL), *_pool_var(ii)); \ + do { BODY; } while (0); \ + pool_put((POOL), (VAR)); \ + } \ + vec_free(_pool_var(dv)); \ +} + #endif /* included_pool_h */ /* |