X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Fpool.h;h=75d4c95ce11cdc20d6e2f44ac8a606e314ae7e05;hb=3ae2873e568dd441a22903ab9f8c7954835b0bf1;hp=2b8e0581e386e5a91abcd6a0165211fd53c701df;hpb=fcd23686c4c5bed8066ea902e0bc1489c0a50daf;p=vpp.git diff --git a/src/vppinfra/pool.h b/src/vppinfra/pool.h index 2b8e0581e38..75d4c95ce11 100644 --- a/src/vppinfra/pool.h +++ b/src/vppinfra/pool.h @@ -185,7 +185,7 @@ pool_free_elts (void *v) First search free list. If nothing is free extend vector of objects. */ -#define pool_get_aligned(P,E,A) \ +#define _pool_get_aligned_internal(P,E,A,Z) \ do { \ pool_header_t * _pool_var (p) = pool_header (P); \ uword _pool_var (l); \ @@ -222,11 +222,22 @@ do { \ /* align */ (A)); \ E = vec_end (P) - 1; \ } \ + if (Z) \ + memset(E, 0, sizeof(*E)); \ } while (0) +/** Allocate an object E from a pool P with alignment A */ +#define pool_get_aligned(P,E,A) _pool_get_aligned_internal(P,E,A,0) + +/** Allocate an object E from a pool P with alignment A and zero it */ +#define pool_get_aligned_zero(P,E,A) _pool_get_aligned_internal(P,E,A,1) + /** Allocate an object E from a pool P (unspecified alignment). */ #define pool_get(P,E) pool_get_aligned(P,E,0) +/** Allocate an object E from a pool P and zero it */ +#define pool_get_zero(P,E) pool_get_aligned_zero(P,E,0) + /** See if pool_get will expand the pool or not */ #define pool_get_aligned_will_expand(P,YESNO,A) \ do { \ @@ -257,6 +268,7 @@ do { \ } \ } while (0) +/** Tell the caller if pool get will expand the pool */ #define pool_get_will_expand(P,YESNO) pool_get_aligned_will_expand(P,YESNO,0) /** Use free bitmap to query whether given element is free. */ @@ -493,7 +505,7 @@ do { \ } /** - * @brief Remove all elemenets from a pool in a safe way + * @brief Remove all elements from a pool in a safe way * * @param VAR each element in the pool * @param POOL The pool to flush