<vector.h>
Type-safe growable arrays, generated per element type by DEFINE_VEC().
Constants
| Name |
Value |
Description |
VEC_ALLOC(sz) |
|
Allocates zeroed memory: KZAlloc() in the kernel, malloc() in userspace. |
VEC_FREE(ptr) |
|
Frees memory from VEC_ALLOC(). |
VEC_ALLOC_T(type, count) |
|
Allocates an array of count elements of type. |
VEC_INITIAL_CAP |
16 |
Capacity of a new vector. |
DEFINE_VEC(name, type) |
|
Defines a vector type for elements of type, and its functions. Generates: - name##_vec_t: { type *data; uint32_t len; uint32_t cap; } - bool name##_vec_init(v): allocates VEC_INITIAL_CAP zeroed slots; false if out of memory. - type *name##_vec_get(v, i): slot i, or NULL if i >= cap. Bounds are checked against the capacity, not the length. - const type *name##_vec_get_const(v, i): the same for a const vector. - int name##_vec_grow(v): doubles the capacity, zeroing the new slots; -1 if out of memory. - void name##_vec_destroy(v): frees the storage. - bool name##_vec_push(v, item): appends a copy of *item, growing as needed; false if out of memory. |