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/serialize.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/vppinfra/serialize.c') diff --git a/src/vppinfra/serialize.c b/src/vppinfra/serialize.c index 64509254b5d..95eca96758a 100644 --- a/src/vppinfra/serialize.c +++ b/src/vppinfra/serialize.c @@ -313,8 +313,8 @@ unserialize_vector_ha (serialize_main_t * m, if (l > max_length) serialize_error (&m->header, clib_error_create ("bad vector length %d", l)); - p = v = _vec_resize ((void *) 0, l, (uword) l * elt_bytes, header_bytes, - /* align */ align); + p = v = _vec_realloc ((void *) 0, l, elt_bytes, header_bytes, + /* align */ align, 0); while (l != 0) { @@ -444,8 +444,7 @@ unserialize_pool_helper (serialize_main_t * m, return 0; } - v = _vec_resize ((void *) 0, l, (uword) l * elt_bytes, sizeof (p[0]), - align); + v = _vec_realloc ((void *) 0, l, elt_bytes, sizeof (p[0]), align, 0); p = pool_header (v); vec_unserialize (m, &p->free_indices, unserialize_vec_32); -- cgit 1.2.3-korg