ip: Router ID included in flow hash
[vpp.git] / src / vppinfra / vec.h
index e983610..e8146af 100644 (file)
@@ -116,8 +116,12 @@ void *vec_resize_allocate_memory (void *v,
     @return v_prime pointer to resized vector, may or may not equal v
 */
 
-#define _vec_resize_numa(V,L,DB,HB,A,S) \
-  _vec_resize_inline(V,L,DB,HB,clib_max((__alignof__((V)[0])),(A)),(S))
+#define _vec_resize_numa(V,L,DB,HB,A,S)                                        \
+({                                                                     \
+  __typeof__ ((V)) _V;                                                 \
+  _V = _vec_resize_inline((void *)V,L,DB,HB,clib_max((__alignof__((V)[0])),(A)),(S)); \
+  _V;                                                                  \
+})
 
 #define _vec_resize(V,L,DB,HB,A)  \
   _vec_resize_numa(V,L,DB,HB,A,VEC_NUMA_UNSPECIFIED)
@@ -205,6 +209,21 @@ _vec_resize_will_expand (void *v,
   return 1;
 }
 
+/** \brief Determine if vector will resize with next allocation
+
+    @param V pointer to a vector
+    @param N number of elements to add
+    @return 1 if vector will resize 0 otherwise
+*/
+
+#define vec_resize_will_expand(V, N)                                          \
+  ({                                                                          \
+    word _v (n) = (N);                                                        \
+    word _v (l) = vec_len (V);                                                \
+    _vec_resize_will_expand ((V), _v (n),                                     \
+                            (_v (l) + _v (n)) * sizeof ((V)[0]), 0, 0);      \
+  })
+
 /** \brief Predicate function, says whether the supplied vector is a clib heap
     object (general version).
 
@@ -330,10 +349,10 @@ do {                                              \
     @param A alignment (may be zero)
     @return V new vector
 */
-#define vec_new_ha(T,N,H,A)                                    \
-({                                                             \
-  word _v(n) = (N);                                            \
-  _vec_resize ((T *) 0, _v(n), _v(n) * sizeof (T), (H), (A));  \
+#define vec_new_ha(T,N,H,A)                                            \
+({                                                                     \
+  word _v(n) = (N);                                                    \
+  (T *)_vec_resize ((T *) 0, _v(n), _v(n) * sizeof (T), (H), (A));     \
 })
 
 /** \brief Create new vector of given type and length
@@ -375,6 +394,8 @@ do {                                                \
 */
 #define vec_free(V) vec_free_h(V,0)
 
+void vec_free_not_inline (void *v);
+
 /**\brief Free vector user header (syntactic sugar)
    @param h vector header
    @void