if (e < l)
vec_add1 (h->free_elts, e - h->elts);
else
- _vec_len (h->elts)--;
+ vec_dec_len (h->elts, 1);
}
/*
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);
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 *
combine_free_blocks (v, p, n);
}
-void *
+__clib_export void *
_heap_alloc (void *v,
uword size,
uword align,
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);
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)
{
return v;
}
-void
+__clib_export void
heap_dealloc (void *v, uword handle)
{
heap_header_t *h = heap_header (v);
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);
return heap_elt_size (v, elt_at (h, handle));
}
-void *
+__clib_export void *
_heap_free (void *v)
{
heap_header_t *h = heap_header (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;
}
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;
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);
return s;
}
-void
+__clib_export void
heap_validate (void *v)
{
heap_header_t *h = heap_header (v);