From 299571aca34d36e637e43cfbba6275662d0d7795 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Sat, 19 Mar 2022 00:07:52 +0100 Subject: vppinfra: vector allocator rework - support of in-place growth of vectors (if there is available space next to existing alloc) - drops the need for alloc_aligned_at_offset from memory allocator, which allows easier swap to different memory allocator and reduces malloc overhead - rework of pool and vec macros to inline functions to improve debuggability - fix alignment - in many cases macros were not using native alignment of the particular datatype. Explicitly setting alignment with XXX_aligned() versions of the macro is not needed anymore in > 99% of cases - fix ASAN usage - avoid use of vector of voids, this was root cause of several bugs found in vec_* and pool_* function where sizeof() was used on voids instead of real vector data type - introduce minimal alignment which is currently 8 bytes, vectors will be always aligned at least to that value (underlay allocator actually always provide 16-byte aligned allocs) Type: improvement Change-Id: I20f4b081bb13bbf7bc0ace85cc4e301787f12fdf Signed-off-by: Damjan Marion --- src/vppinfra/pool.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/vppinfra/pool.c') diff --git a/src/vppinfra/pool.c b/src/vppinfra/pool.c index ff7278b1dcd..2bbfe60d320 100644 --- a/src/vppinfra/pool.c +++ b/src/vppinfra/pool.c @@ -38,7 +38,7 @@ #include __clib_export void -_pool_init_fixed (void **pool_ptr, u32 elt_size, u32 max_elts) +_pool_init_fixed (void **pool_ptr, uword elt_size, uword max_elts, uword align) { uword *b; pool_header_t *ph; @@ -48,9 +48,7 @@ _pool_init_fixed (void **pool_ptr, u32 elt_size, u32 max_elts) ASSERT (elt_size); ASSERT (max_elts); - v = - vec_resize_allocate_memory (0, max_elts, elt_size * max_elts, - sizeof (pool_header_t), CLIB_CACHE_LINE_BYTES); + v = _vec_realloc (0, max_elts, elt_size, sizeof (pool_header_t), align, 0); ph = pool_header (v); ph->max_elts = max_elts; -- cgit 1.2.3-korg