45 word length_increment,
50 uword old_alloc_bytes, new_alloc_bytes;
55 data_bytes += header_bytes;
62 memset (
new, 0, data_bytes);
63 v =
new + header_bytes;
64 _vec_len (v) = length_increment;
68 vh->
len += length_increment;
69 old = v - header_bytes;
77 if (data_bytes <= old_alloc_bytes)
80 new_alloc_bytes = (old_alloc_bytes * 3) / 2;
81 if (new_alloc_bytes < data_bytes)
82 new_alloc_bytes = data_bytes;
92 (
"vec_resize fails, length increment %d, data bytes %d, alignment %d",
93 length_increment, data_bytes, data_align);
103 memset (v + old_alloc_bytes, 0, new_alloc_bytes - old_alloc_bytes);
105 return v + header_bytes;
121 main (
int argc,
char *argv[])
123 word n = atoi (argv[1]);
131 FOO *foos = vec_init (FOO, 10), *f;
137 for (i = 0; i < n; i++)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
sll srl srl sll sra u16x4 i
void * vec_resize_allocate_memory(void *v, word length_increment, uword data_bytes, uword header_bytes, uword data_align)
Low-level resize allocation function, usually not called directly.
static void * clib_mem_alloc_aligned_at_offset(uword size, uword align, uword align_offset, int os_out_of_memory_on_failure)
#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.
add_epi add_epi sub_epi sub_epi adds_epu subs_epu i16x8 y
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)...
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...
#define vec_free(V)
Free vector's memory (no header).
#define clib_memcpy(a, b, c)
static uword clib_mem_size(void *p)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
static void clib_mem_free(void *p)
static uword clib_mem_is_heap_object(void *p)
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".