vppinfra: add vec_new_heap()
Type: improvement
Change-Id: Iab3d65b6276829ad1e522e66380d1797e37579b8
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vppinfra/test_vec.c b/src/vppinfra/test_vec.c
index 4bfffd1..f32cd7f 100644
--- a/src/vppinfra/test_vec.c
+++ b/src/vppinfra/test_vec.c
@@ -676,7 +676,7 @@
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 1dc300a..bfb7b1b 100644
--- a/src/vppinfra/vec.h
+++ b/src/vppinfra/vec.h
@@ -320,10 +320,11 @@
@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 @@
@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 @@
@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