summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/fifo.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-03-16 17:57:29 +0100
committerFlorin Coras <florin.coras@gmail.com>2022-03-17 20:31:14 +0000
commit1da361f9ea525663a1141c3665a67df5e81c4133 (patch)
tree301fd513bc709e68b31d9671e63e9894b8aee36b /src/vppinfra/fifo.c
parent2b702da86c42267682b30a888299b89718bc46e8 (diff)
vppinfra: store vector header size and alignment into header
On the forst vector alloc values are stored into header. Later, when vector grows values from header are used istead of provided ones. In the debug image code will assert if same values are not provided. Type: improvement Change-Id: I8fdcfa495e9c1df0f6392c90f634e8c74b73b328 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/fifo.c')
-rw-r--r--src/vppinfra/fifo.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/vppinfra/fifo.c b/src/vppinfra/fifo.c
index 52d65ae1f37..1ef1754bbbf 100644
--- a/src/vppinfra/fifo.c
+++ b/src/vppinfra/fifo.c
@@ -79,8 +79,9 @@
__clib_export void *
_clib_fifo_resize (void *v_old, uword n_new_elts, uword elt_bytes)
{
- void *v_new, *end, *head;
- uword n_old_elts, header_bytes;
+ void *end, *head;
+ u8 *v_new = 0;
+ uword n_old_elts;
uword n_copy_bytes, n_zero_bytes;
clib_fifo_header_t *f_new, *f_old;
@@ -91,15 +92,12 @@ _clib_fifo_resize (void *v_old, uword n_new_elts, uword elt_bytes)
else
n_new_elts = max_pow2 (n_new_elts);
- header_bytes = vec_header_bytes (sizeof (clib_fifo_header_t));
-
- v_new = clib_mem_alloc_no_fail (n_new_elts * elt_bytes + header_bytes);
- v_new += header_bytes;
+ vec_alloc_ha (v_new, n_new_elts * elt_bytes, sizeof (clib_fifo_header_t), 0);
+ _vec_len (v_new) = n_new_elts;
f_new = clib_fifo_header (v_new);
f_new->head_index = 0;
f_new->tail_index = n_old_elts;
- _vec_len (v_new) = n_new_elts;
/* Copy old -> new. */
n_copy_bytes = n_old_elts * elt_bytes;