diff options
author | Damjan Marion <damarion@cisco.com> | 2022-04-06 12:31:15 +0200 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2022-04-06 12:22:20 +0000 |
commit | 43daea8309e9f58468ad562e15b81c5a4d8aa2b2 (patch) | |
tree | 92b43210c8182e7c6152301b6b427445a04089d9 /src/vppinfra/vec.h | |
parent | 2b6479c07ed67940e47a676f3386a2df21c16655 (diff) |
vppinfra: add vec_new_heap()
Type: improvement
Change-Id: Iab3d65b6276829ad1e522e66380d1797e37579b8
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/vec.h')
-rw-r--r-- | src/vppinfra/vec.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/vppinfra/vec.h b/src/vppinfra/vec.h index 1dc300ad1ea..bfb7b1b7fc6 100644 --- a/src/vppinfra/vec.h +++ b/src/vppinfra/vec.h @@ -320,10 +320,11 @@ _vec_resize (void **vp, uword n_add, uword hdr_sz, uword align, uword elt_sz) @param N number of elements to add @param H header size in bytes (may be zero) @param A alignment (may be zero) + @param P heap (may be zero) @return V new vector */ -#define vec_new_ha(T, N, H, A) \ - _vec_realloc (0, N, sizeof (T), H, _vec_align ((T *) 0, A), 0) +#define vec_new_generic(T, N, H, A, P) \ + _vec_realloc (0, N, sizeof (T), H, _vec_align ((T *) 0, A), P) /** \brief Create new vector of given type and length (unspecified alignment, no header). @@ -332,7 +333,7 @@ _vec_resize (void **vp, uword n_add, uword hdr_sz, uword align, uword elt_sz) @param N number of elements to add @return V new vector */ -#define vec_new(T,N) vec_new_ha(T,N,0,0) +#define vec_new(T, N) vec_new_generic (T, N, 0, 0, 0) /** \brief Create new vector of given type and length (alignment specified, no header). @@ -341,7 +342,16 @@ _vec_resize (void **vp, uword n_add, uword hdr_sz, uword align, uword elt_sz) @param A alignment (may be zero) @return V new vector */ -#define vec_new_aligned(T,N,A) vec_new_ha(T,N,0,A) +#define vec_new_aligned(T, N, A) vec_new_generic (T, N, 0, A, 0) +/** \brief Create new vector of given type and length + (heap specified, no header). + + @param T type of elements in new vector + @param N number of elements to add + @param P heap (may be zero) + @return V new vector +*/ +#define vec_new_heap(T, N, P) vec_new_generic (T, N, 0, 0, P) /** \brief Free vector's memory (no header). @param V pointer to a vector |