diff options
author | Damjan Marion <damarion@cisco.com> | 2022-04-11 18:41:49 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2022-04-12 22:40:52 +0000 |
commit | e4fa1d2f6b8721318c0f104f2615588b5d4e0441 (patch) | |
tree | 70d33a24bae0b9aa993fe6e03960e2b135accb70 /src/vppinfra/heap.h | |
parent | 65e770d895b13a6e5c73d13f436872ea626e47e3 (diff) |
vppinfra: vector perf improvements
Type: improvement
Change-Id: I37c187af80c21b8fb1ab15af112527a837e0df9e
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/heap.h')
-rw-r--r-- | src/vppinfra/heap.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/vppinfra/heap.h b/src/vppinfra/heap.h index f496fe07b2e..45f3131a45b 100644 --- a/src/vppinfra/heap.h +++ b/src/vppinfra/heap.h @@ -185,6 +185,9 @@ always_inline void * _heap_dup (void *v_old, uword v_bytes) { heap_header_t *h_old, *h_new; + vec_attr_t va = { .align = HEAP_DATA_ALIGN, + .hdr_sz = sizeof (heap_header_t), + .elt_sz = 1 }; void *v_new; h_old = heap_header (v_old); @@ -192,8 +195,7 @@ _heap_dup (void *v_old, uword v_bytes) if (!v_old) return v_old; - v_new = _vec_realloc (0, _vec_len (v_old), 1, sizeof (heap_header_t), - HEAP_DATA_ALIGN, 0); + v_new = _vec_alloc_internal (_vec_len (v_old), &va); h_new = heap_header (v_new); heap_dup_header (h_old, h_new); clib_memcpy_fast (v_new, v_old, v_bytes); @@ -212,8 +214,10 @@ uword heap_bytes (void *v); always_inline void * _heap_new (u32 len, u32 n_elt_bytes) { - void *v = _vec_realloc ((void *) 0, len, n_elt_bytes, sizeof (heap_header_t), - HEAP_DATA_ALIGN, 0); + vec_attr_t va = { .align = HEAP_DATA_ALIGN, + .hdr_sz = sizeof (heap_header_t), + .elt_sz = n_elt_bytes }; + void *v = _vec_alloc_internal (len, &va); heap_header (v)->elt_bytes = n_elt_bytes; return v; } |