e = p + index * elt_sz;
ph->free_bitmap =
clib_bitmap_andnoti_notrim (ph->free_bitmap, index);
- _vec_len (ph->free_indices) = n_free - 1;
+ vec_set_len (ph->free_indices, n_free - 1);
CLIB_MEM_UNPOISON (e, elt_sz);
goto done;
}
if (ph->max_elts)
{
ph->free_indices[_vec_len (ph->free_indices)] = index;
- _vec_len (ph->free_indices) += 1;
+ vec_inc_len (ph->free_indices, 1);
}
else
vec_add1 (ph->free_indices, index);
/** Allocate N more free elements to pool (general version). */
static_always_inline void
-_pool_alloc (void **pp, uword n_elts, uword align, uword elt_sz)
+_pool_alloc (void **pp, uword n_elts, uword align, void *heap, uword elt_sz)
{
pool_header_t *ph = pool_header (pp[0]);
uword len = vec_len (pp[0]);
}
pp[0] = _vec_realloc_inline (pp[0], len + n_elts, elt_sz,
- sizeof (pool_header_t), align, 0);
- _vec_len (pp[0]) = len;
+ sizeof (pool_header_t), align, heap);
+ _vec_set_len (pp[0], len, elt_sz);
CLIB_MEM_POISON (pp[0] + len * elt_sz, n_elts * elt_sz);
ph = pool_header (pp[0]);
vec_resize (ph->free_indices, n_elts);
- _vec_len (ph->free_indices) -= n_elts;
+ vec_dec_len (ph->free_indices, n_elts);
clib_bitmap_vec_validate (ph->free_bitmap, len + n_elts - 1);
}
-#define pool_alloc_aligned(P, N, A) \
- _pool_alloc ((void **) &(P), N, _vec_align (P, A), _vec_elt_sz (P))
+#define pool_alloc_aligned_heap(P, N, A, H) \
+ _pool_alloc ((void **) &(P), N, _vec_align (P, A), H, _vec_elt_sz (P))
-/** Allocate N more free elements to pool (unspecified alignment). */
-#define pool_alloc(P,N) pool_alloc_aligned(P,N,0)
+#define pool_alloc_heap(P, N, H) pool_alloc_aligned_heap (P, N, 0, H)
+#define pool_alloc_aligned(P, N, A) pool_alloc_aligned_heap (P, N, A, 0)
+#define pool_alloc(P, N) pool_alloc_aligned_heap (P, N, 0, 0)
static_always_inline void *
_pool_dup (void *p, uword align, uword elt_sz)