hs-test: point gdb to vpp source files
[vpp.git] / src / vppinfra / heap.c
index e91dc64..7db8142 100644 (file)
@@ -139,7 +139,7 @@ elt_delete (heap_header_t * h, heap_elt_t * e)
   if (e < l)
     vec_add1 (h->free_elts, e - h->elts);
   else
-    _vec_len (h->elts)--;
+    vec_dec_len (h->elts, 1);
 }
 
 /*
@@ -200,7 +200,7 @@ elt_new (heap_header_t * h)
   if ((l = vec_len (h->free_elts)) > 0)
     {
       e = elt_at (h, h->free_elts[l - 1]);
-      _vec_len (h->free_elts) -= 1;
+      vec_dec_len (h->free_elts, 1);
     }
   else
     vec_add2 (h->elts, e, 1);
@@ -276,7 +276,7 @@ remove_free_block (void *v, uword b, uword i)
       h->free_lists[b][i] = t;
       set_free_elt (v, elt_at (h, t), i);
     }
-  _vec_len (h->free_lists[b]) = l - 1;
+  vec_set_len (h->free_lists[b], l - 1);
 }
 
 static heap_elt_t *
@@ -382,7 +382,7 @@ dealloc_elt (void *v, heap_elt_t * e)
     combine_free_blocks (v, p, n);
 }
 
-void *
+__clib_export void *
 _heap_alloc (void *v,
             uword size,
             uword align,
@@ -413,6 +413,9 @@ _heap_alloc (void *v,
   if (!e)
     {
       uword max_len;
+      vec_attr_t va = { .elt_sz = elt_bytes,
+                       .hdr_sz = sizeof (h[0]),
+                       .align = HEAP_DATA_ALIGN };
 
       offset = vec_len (v);
       max_len = heap_get_max_len (v);
@@ -422,12 +425,9 @@ _heap_alloc (void *v,
 
       h = heap_header (v);
       if (!v || !(h->flags & HEAP_IS_STATIC))
-       v = _vec_resize (v,
-                        align_size,
-                        (offset + align_size) * elt_bytes,
-                        sizeof (h[0]), HEAP_DATA_ALIGN);
+       v = _vec_realloc_internal (v, offset + align_size, &va);
       else
-       _vec_len (v) += align_size;
+       vec_inc_len (v, align_size);
 
       if (offset == 0)
        {
@@ -496,7 +496,7 @@ error:
   return v;
 }
 
-void
+__clib_export void
 heap_dealloc (void *v, uword handle)
 {
   heap_header_t *h = heap_header (v);
@@ -597,7 +597,7 @@ combine_free_blocks (void *v, heap_elt_t * e0, heap_elt_t * e1)
   set_free_elt (v, elt_at (h, g.index), g.bin_index);
 }
 
-uword
+__clib_export uword
 heap_len (void *v, word handle)
 {
   heap_header_t *h = heap_header (v);
@@ -607,7 +607,7 @@ heap_len (void *v, word handle)
   return heap_elt_size (v, elt_at (h, handle));
 }
 
-void *
+__clib_export void *
 _heap_free (void *v)
 {
   heap_header_t *h = heap_header (v);
@@ -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;
 }
 
@@ -640,10 +640,10 @@ heap_bytes (void *v)
   bytes = sizeof (h[0]);
   bytes += vec_len (v) * sizeof (h->elt_bytes);
   for (b = 0; b < vec_len (h->free_lists); b++)
-    bytes += vec_capacity (h->free_lists[b], 0);
+    bytes += vec_mem_size (h->free_lists[b]);
   bytes += vec_bytes (h->free_lists);
-  bytes += vec_capacity (h->elts, 0);
-  bytes += vec_capacity (h->free_elts, 0);
+  bytes += vec_mem_size (h->elts);
+  bytes += vec_mem_size (h->free_elts);
   bytes += vec_bytes (h->used_elt_bitmap);
 
   return bytes;
@@ -694,8 +694,8 @@ debug_elt (u8 * s, void *v, word i, word n)
   return s;
 }
 
-u8 *
-format_heap (u8 * s, va_list * va)
+__clib_export u8 *
+format_heap (u8 *s, va_list *va)
 {
   void *v = va_arg (*va, void *);
   uword verbose = va_arg (*va, uword);
@@ -722,7 +722,7 @@ format_heap (u8 * s, va_list * va)
   return s;
 }
 
-void
+__clib_export void
 heap_validate (void *v)
 {
   heap_header_t *h = heap_header (v);