summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/heap.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-04-04 22:40:45 +0200
committerDamjan Marion <dmarion@me.com>2022-04-04 23:17:13 +0000
commit8bea589cfe0fca1a6f560e16ca66a4cf199041a2 (patch)
treecf2767f8f5f31344468b65e14baa3f1a4c85fb91 /src/vppinfra/heap.c
parenta2b358b1faf6e762e1d29a931d83c7735ac9a77d (diff)
vppinfra: make _vec_len() read-only
Use of _vec_len() to set vector length breaks address sanitizer. Users should use vec_set_len(), vec_inc_len(), vec_dec_len () instead. Type: improvement Change-Id: I441ae948771eb21c23a61f3ff9163bdad74a2cb8 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/heap.c')
-rw-r--r--src/vppinfra/heap.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/vppinfra/heap.c b/src/vppinfra/heap.c
index 47b6cf53214..066756b4db9 100644
--- 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
- _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 *
@@ -425,7 +425,7 @@ _heap_alloc (void *v,
v = _vec_realloc (v, offset + align_size, elt_bytes, sizeof (h[0]),
HEAP_DATA_ALIGN, 0);
else
- _vec_len (v) += align_size;
+ vec_inc_len (v, align_size);
if (offset == 0)
{