vppinfra: deprecate vec_free_h() 03/35703/3
authorDamjan Marion <damarion@cisco.com>
Thu, 17 Mar 2022 17:29:32 +0000 (18:29 +0100)
committerDamjan Marion <dmarion@me.com>
Fri, 18 Mar 2022 13:16:30 +0000 (13:16 +0000)
vec_free() does the work

Type: refactor
Change-Id: I8a97607c3b2f58d116863642b32b55525dc15d88
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/vppinfra/fifo.h
src/vppinfra/heap.c
src/vppinfra/pool.h
src/vppinfra/ring.h
src/vppinfra/test_heap.c
src/vppinfra/test_vec.c
src/vppinfra/vec.h

index 496f5dd..f1ba7aa 100644 (file)
@@ -254,7 +254,7 @@ clib_fifo_tail_index (void *v)
 #define clib_fifo_head(v) ((v) + clib_fifo_head_index (v))
 #define clib_fifo_tail(v) ((v) + clib_fifo_tail_index (v))
 
-#define clib_fifo_free(f) vec_free_h((f),sizeof(clib_fifo_header_t))
+#define clib_fifo_free(f) vec_free ((f))
 
 always_inline uword
 clib_fifo_elt_index (void *v, uword i)
index b724f88..bc3e8cb 100644 (file)
@@ -624,7 +624,7 @@ _heap_free (void *v)
   vec_free (h->free_elts);
   vec_free (h->small_free_elt_free_index);
   if (!(h->flags & HEAP_IS_STATIC))
-    vec_free_h (v, sizeof (h[0]));
+    vec_free (v);
   return v;
 }
 
index 1b1d54c..9fca656 100644 (file)
@@ -427,7 +427,7 @@ _pool_free (void *v)
   clib_bitmap_free (p->free_bitmap);
 
   vec_free (p->free_indices);
-  vec_free_h (v, pool_aligned_header_bytes);
+  vec_free (v);
   return 0;
 }
 
index 2f90b82..52b4261 100644 (file)
@@ -56,7 +56,7 @@ clib_ring_new_inline (void **p, u32 elt_bytes, u32 size, u32 align)
 #define clib_ring_new(ring, size) \
 { clib_ring_new_inline ((void **)&(ring), sizeof(ring[0]), size, 0);}
 
-#define clib_ring_free(f) vec_free_h((f), sizeof(clib_ring_header_t))
+#define clib_ring_free(f) vec_free ((f))
 
 always_inline u32
 clib_ring_n_enq (void *v)
index 0fd6bf7..00c896e 100644 (file)
@@ -189,7 +189,7 @@ main (int argc, char *argv[])
   vec_free (handles);
 
   if (fixed_size)
-    vec_free_h (h, sizeof (heap_header_t));
+    vec_free (h);
 
   if (verbose)
     fformat (stderr, "%U\n", format_clib_mem_usage, /* verbose */ 0);
index 28d945e..cd46137 100644 (file)
@@ -259,7 +259,7 @@ validate_vec_free (elt_t * vec)
 static elt_t *
 validate_vec_free_h (elt_t * vec, uword hdr_bytes)
 {
-  vec_free_h (vec, hdr_bytes);
+  vec_free (vec);
   ASSERT (vec == NULL);
   return vec;
 }
@@ -799,7 +799,7 @@ run_validator_wh (uword iter)
        {
        case OP_IS_VEC_INIT_H:
          num_elts = bounded_random_u32 (&g_seed, 0, MAX_CHANGE);
-         vec_free_h (vec, sizeof (hdr_t));
+         vec_free (vec);
          VERBOSE2 ("vec_init_h(), new elts %d\n", num_elts);
          vec = validate_vec_init_h (num_elts, sizeof (hdr_t));
          break;
@@ -840,7 +840,7 @@ run_validator_wh (uword iter)
     }
 
   validate_vec (vec, sizeof (hdr_t));
-  vec_free_h (vec, sizeof (hdr_t));
+  vec_free (vec);
 }
 
 static void
index e8eb586..3f50bd2 100644 (file)
@@ -373,13 +373,11 @@ do {                                              \
 */
 #define vec_new_aligned(T,N,A) vec_new_ha(T,N,0,A)
 
-/** \brief Free vector's memory (general version)
-
+/** \brief Free vector's memory (no header).
     @param V pointer to a vector
-    @param H size of header in bytes
     @return V (value-result parameter, V=0)
 */
-#define vec_free_h(V, H)                                                      \
+#define vec_free(V)                                                           \
   do                                                                          \
     {                                                                         \
       if (V)                                                                  \
@@ -390,12 +388,6 @@ do {                                               \
     }                                                                         \
   while (0)
 
-/** \brief Free vector's memory (no header).
-    @param V pointer to a vector
-    @return V (value-result parameter, V=0)
-*/
-#define vec_free(V) vec_free_h(V,0)
-
 void vec_free_not_inline (void *v);
 
 /**\brief Free vector user header (syntactic sugar)