aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-04-06 12:31:15 +0200
committerOle Tr�an <otroan@employees.org>2022-04-06 12:22:20 +0000
commit43daea8309e9f58468ad562e15b81c5a4d8aa2b2 (patch)
tree92b43210c8182e7c6152301b6b427445a04089d9
parent2b6479c07ed67940e47a676f3386a2df21c16655 (diff)
vppinfra: add vec_new_heap()
Type: improvement Change-Id: Iab3d65b6276829ad1e522e66380d1797e37579b8 Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--src/vppinfra/test_vec.c2
-rw-r--r--src/vppinfra/vec.h18
2 files changed, 15 insertions, 5 deletions
diff --git a/src/vppinfra/test_vec.c b/src/vppinfra/test_vec.c
index 4bfffd121a2..f32cd7ffb82 100644
--- a/src/vppinfra/test_vec.c
+++ b/src/vppinfra/test_vec.c
@@ -676,7 +676,7 @@ validate_vec_init_h (uword num_elts, uword hdr_bytes)
uword len;
elt_t *new;
- new = vec_new_ha (elt_t, num_elts, hdr_bytes, 0);
+ new = vec_new_generic (elt_t, num_elts, hdr_bytes, 0, 0);
len = vec_len (new);
ASSERT (len == num_elts);
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