45 word length_increment,
51 uword old_alloc_bytes, new_alloc_bytes;
57 data_bytes += header_bytes;
73 v =
new + header_bytes;
74 _vec_len (v) = length_increment;
75 _vec_numa (v) = numa_id;
81 vh->
len += length_increment;
82 old = v - header_bytes;
90 if (data_bytes <= old_alloc_bytes)
98 #if CLIB_VECTOR_GROW_BY_ONE > 0 99 new_alloc_bytes = data_bytes;
101 new_alloc_bytes = (old_alloc_bytes * 3) / 2;
102 if (new_alloc_bytes < data_bytes)
103 new_alloc_bytes = data_bytes;
114 (
"vec_resize fails, length increment %d, data bytes %d, alignment %d",
115 length_increment, data_bytes, data_align);
127 memset (v + old_alloc_bytes, 0, new_alloc_bytes - old_alloc_bytes);
130 _vec_numa ((v + header_bytes)) = numa_id;
134 return v + header_bytes;
162 main (
int argc,
char *argv[])
164 word n = atoi (argv[1]);
172 FOO *foos = vec_init (FOO, 10), *f;
178 for (i = 0; i < n; i++)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define CLIB_MEM_UNPOISON(a, s)
static void * clib_mem_alloc_aligned_at_offset(uword size, uword align, uword align_offset, int os_out_of_memory_on_failure)
void * vec_resize_allocate_memory(void *v, word length_increment, uword data_bytes, uword header_bytes, uword data_align, uword numa_id)
Low-level resize allocation function, usually not called directly.
#define clib_memcpy_fast(a, b, c)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define VEC_NUMA_UNSPECIFIED
uword clib_mem_is_vec_h(void *v, uword header_bytes)
Predicate function, says whether the supplied vector is a clib heap object (general version)...
u32 vec_len_not_inline(void *v)
static uword vec_header_bytes(uword header_bytes)
#define vec_insert(V, N, M)
Insert N vector elements starting at element M, initialize new elements to zero (no header...
static void * clib_mem_get_per_cpu_heap(void)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
static uword clib_mem_size(void *p)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
void vec_free_not_inline(void *v)
static void clib_mem_free(void *p)
static uword clib_mem_is_heap_object(void *p)
static void * clib_mem_get_per_numa_heap(u32 numa_id)
static void * clib_mem_set_per_cpu_heap(u8 *new_heap)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
int main(int argc, char **argv)
static void * vec_header(void *v, uword header_bytes)
Find a user vector header.
#define clib_panic(format, args...)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
#define CLIB_MEM_POISON(a, s)