diff options
Diffstat (limited to 'src/vppinfra/fifo.c')
-rw-r--r-- | src/vppinfra/fifo.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/vppinfra/fifo.c b/src/vppinfra/fifo.c index 52d65ae1f37..2b1cfea6fe0 100644 --- a/src/vppinfra/fifo.c +++ b/src/vppinfra/fifo.c @@ -77,12 +77,16 @@ */ __clib_export void * -_clib_fifo_resize (void *v_old, uword n_new_elts, uword elt_bytes) +_clib_fifo_resize (void *v_old, uword n_new_elts, uword align, 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; + vec_attr_t va = { .elt_sz = elt_bytes, + .hdr_sz = sizeof (clib_fifo_header_t), + .align = align }; n_old_elts = clib_fifo_elts (v_old); n_new_elts += n_old_elts; @@ -91,15 +95,10 @@ _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; - + v_new = _vec_alloc_internal (n_new_elts, &va); 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; |