@param DST destination
@param SRC source
*/
-#define vec_copy(DST,SRC) clib_memcpy_fast (DST, SRC, vec_len (DST) * \
- sizeof ((DST)[0]))
+#define vec_copy(DST, SRC) \
+ clib_memcpy_fast (DST, SRC, vec_len (DST) * _vec_elt_sz (DST))
/** \brief Clone a vector. Make a new vector with the
same size as a given vector but possibly with a different type.
{
clib_memset_u8 (v + (first * elt_sz), 0, count * elt_sz);
}
-#define vec_zero_elts(V, F, C) _vec_zero_elts (V, F, C, sizeof ((V)[0]))
+#define vec_zero_elts(V, F, C) _vec_zero_elts (V, F, C, _vec_elt_sz (V))
static_always_inline void
_vec_validate (void **vp, uword index, uword header_size, uword align,
}
#define vec_validate_hap(V, I, H, A, P) \
- _vec_validate ((void **) &(V), I, H, _vec_align (V, A), 0, sizeof ((V)[0]))
+ _vec_validate ((void **) &(V), I, H, _vec_align (V, A), 0, _vec_elt_sz (V))
/** \brief Make sure vector is long enough for given index
(no header, unspecified alignment)
@param vec vector to sort
@param f comparison function
*/
-#define vec_sort_with_function(vec,f) \
-do { \
- if (vec_len (vec) > 1) \
- qsort (vec, vec_len (vec), sizeof (vec[0]), (void *) (f)); \
-} while (0)
+#define vec_sort_with_function(vec, f) \
+ do \
+ { \
+ if (vec_len (vec) > 1) \
+ qsort (vec, vec_len (vec), _vec_elt_sz (vec), (void *) (f)); \
+ } \
+ while (0)
/** \brief Make a vector containing a NULL terminated c-string.
(((s) + sizeof (uword) - 1) &~ (sizeof (uword) - 1))
#define _vec_is_void(P) \
__builtin_types_compatible_p (__typeof__ ((P)[0]), void)
-#define _vec_elt_sz(V) __vec_elt_sz (sizeof ((V)[0]), _vec_is_void (V))
+#define _vec_elt_sz(V) \
+ __vec_elt_sz (sizeof ((V)[0]), _vec_is_void (V)) /* NOLINT */
#define _vec_align(V, A) __vec_align (__alignof__((V)[0]), A)
always_inline __clib_nosanitize_addr uword
/** \brief Number of data bytes in vector. */
-#define vec_bytes(v) (vec_len (v) * sizeof (v[0]))
+#define vec_bytes(v) (vec_len (v) * _vec_elt_sz (v))
/**
* Return size of memory allocated for the vector