Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
api: nat44_ed - Mark old message versions as deprecated
[vpp.git]
/
src
/
vppinfra
/
heap.c
diff --git
a/src/vppinfra/heap.c
b/src/vppinfra/heap.c
index
b81e1e1
..
7db8142
100644
(file)
--- a/
src/vppinfra/heap.c
+++ b/
src/vppinfra/heap.c
@@
-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
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]);
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);
}
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);
}
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 *
}
static heap_elt_t *
@@
-413,6
+413,9
@@
_heap_alloc (void *v,
if (!e)
{
uword max_len;
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);
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))
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
else
-
_vec_len (v) += align_size
;
+
vec_inc_len (v, align_size)
;
if (offset == 0)
{
if (offset == 0)
{
@@
-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);
}
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);
heap_len (void *v, word handle)
{
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->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;
}
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 = 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_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;
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;
}
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);
{
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;
}
return s;
}
-void
+
__clib_export
void
heap_validate (void *v)
{
heap_header_t *h = heap_header (v);
heap_validate (void *v)
{
heap_header_t *h = heap_header (v);