tcp: cleanup syn-sent and bulk buffer translation
[vpp.git] / src / vppinfra / heap.c
index 2a5fb5c..b81e1e1 100644 (file)
@@ -297,6 +297,7 @@ search_free_list (void *v, uword size)
        /* Find an object that is large enough.
           Search list in reverse so that more recently freed objects will be
           allocated again sooner. */
+       u8 found = 0;
        do
          {
            l--;
@@ -304,12 +305,15 @@ search_free_list (void *v, uword size)
            f = elt_at (h, f_index);
            f_size = heap_elt_size (v, f);
            if ((s = f_size - size) >= 0)
-             break;
+             {
+               found = 1;
+               break;
+             }
          }
-       while (l >= 0);
+       while (l > 0);
 
        /* If we fail to find a large enough object, try the next larger size. */
-       if (l < 0)
+       if (found == 0)
          continue;
 
        ASSERT (heap_is_free (f));
@@ -378,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,
@@ -492,7 +496,7 @@ error:
   return v;
 }
 
-void
+__clib_export void
 heap_dealloc (void *v, uword handle)
 {
   heap_header_t *h = heap_header (v);
@@ -603,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);
@@ -698,7 +702,7 @@ format_heap (u8 * s, va_list * va)
   heap_header_t *h = heap_header (v);
   heap_header_t zero;
 
-  memset (&zero, 0, sizeof (zero));
+  clib_memset (&zero, 0, sizeof (zero));
 
   if (!v)
     h = &zero;