summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/vec_bootstrap.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra/vec_bootstrap.h')
-rw-r--r--src/vppinfra/vec_bootstrap.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/vppinfra/vec_bootstrap.h b/src/vppinfra/vec_bootstrap.h
index fec0df08143..7fb016fe8d2 100644
--- a/src/vppinfra/vec_bootstrap.h
+++ b/src/vppinfra/vec_bootstrap.h
@@ -142,12 +142,6 @@ vec_aligned_header_end (void *v, uword header_bytes, uword align)
#define vec_len(v) ((v) ? _vec_len(v) : 0)
-/** \brief Reset vector length to zero
- NULL-pointer tolerant
-*/
-
-#define vec_reset_length(v) do { if (v) _vec_len (v) = 0; } while (0)
-
/** \brief Number of data bytes in vector. */
#define vec_bytes(v) (vec_len (v) * sizeof (v[0]))
@@ -165,6 +159,19 @@ vec_aligned_header_end (void *v, uword header_bytes, uword align)
/** \brief Total number of elements that can fit into vector. */
#define vec_max_len(v) (vec_capacity(v,0) / sizeof (v[0]))
+/** \brief Set vector length to a user-defined value */
+#define vec_set_len(v, l) do { \
+ ASSERT(v); \
+ ASSERT((l) <= vec_max_len(v)); \
+ _vec_len(v) = (l); \
+} while (0)
+
+/** \brief Reset vector length to zero
+ NULL-pointer tolerant
+*/
+
+#define vec_reset_length(v) do { if (v) vec_set_len (v, 0); } while (0)
+
/** \brief End (last data address) of vector. */
#define vec_end(v) ((v) + vec_len (v))