From 41a1bbffc6238b0ed52b55f58ba884fe2f26e11f Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Fri, 11 Mar 2022 10:58:55 -0800 Subject: vppinfra: fix vec capacity Rename vec_capacity to vec_mem_size as it returned the size of the underlying memory allocation not the number of bytes that can be used for vector elements. Add new vec_max_elts macro that returns number of elements that can fit into generic vector. Type: fix Signed-off-by: Florin Coras Change-Id: I2e53a2bfa6e56a89af62d6ddc073ead58b8c49bb --- src/vppinfra/pool.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/vppinfra/pool.h') diff --git a/src/vppinfra/pool.h b/src/vppinfra/pool.h index 284e23d8e0a..32b42b175b3 100644 --- a/src/vppinfra/pool.h +++ b/src/vppinfra/pool.h @@ -162,11 +162,8 @@ pool_header_bytes (void *v) /** Local variable naming macro. */ #define _pool_var(v) _pool_##v -/** Number of bytes that can fit into pool with current allocation */ -#define pool_capacity(P) vec_capacity (P, pool_aligned_header_bytes) - /** Number of elements that can fit into pool with current allocation */ -#define pool_max_len(P) (pool_capacity (P) / sizeof (P[0])) +#define pool_max_len(P) vec_max_elts (P, pool_aligned_header_bytes) /** Number of free elements in pool */ #define pool_free_elts(P) \ -- cgit 1.2.3-korg