24#pragma clang final(YAVL_VEC_H)
107#define YAVL_VEC_T_ALLOCATOR ((yavl_vec_t){})
yavl_vec_res_t
Operation result codes.
Definition vec.h:39
@ YAVL_VEC_RES_FAIL
Generic operation failure.
Definition vec.h:47
@ YAVL_VEC_RES_OOM
Out-of-memory, allocator failures.
Definition vec.h:41
@ YAVL_VEC_RES_NULL
Null pointer exception.
Definition vec.h:43
@ YAVL_VEC_RES_OK
Operation success.
Definition vec.h:45
yavl_vec_errorable_t yavl_vec_toarray(yavl_vec_t *const vec, size_t *const final_len)
Finalizes vector, to result it in statically-sized array. This allows you to drop vector metadata.
yavl_vec_res_t yavl_vec_set(yavl_vec_t *const vec, size_t offset, const void *const data)
Sets offset -th element of vector to data.
yavl_vec_res_t yavl_vec_free(yavl_vec_t *const vec)
Frees heap in vector and zeroes the entire object.
yavl_vec_res_t yavl_vec_init(yavl_vec_t *const vec, size_t data_align, size_t data_reserv)
Initializes a new vector. Frees memory if it is already allocated.
yavl_vec_errorable_t yavl_vec_pop(yavl_vec_t *const vec, const size_t num_el)
Pops last elements out of vector. Doesn't free memory yet.
yavl_vec_res_t yavl_vec_fromarray(yavl_vec_t *const vec, void *const array, const size_t alignment, const size_t length)
Converts given statically-sized array to the dynamic ones.
yavl_vec_res_t yavl_vec_fit(yavl_vec_t *const vec)
Resizes vector space to the current size.
yavl_vec_res_t yavl_vec_scale(yavl_vec_t *const vec, size_t new_reservd)
Resizes memory space to the given size.
bool yavl_vec_chkptr(const yavl_vec_t *const vec, const void *const ptr)
Try to validate if the ptr pointer is in bounds of vec vector. This might be useful to ensure freshne...
yavl_vec_res_t yavl_vec_push(yavl_vec_t *const vec, const void *const data, const size_t num_el)
Pushes data to vector.
yavl_vec_res_t yavl_vec_get(yavl_vec_t *const vec, size_t offset, void *const out)
Gets element at offset and stores it in out memory.
A return package which contains both result code and data.
Definition vec.h:54
void *const mem
Data pointer, might be NULL on fatal failures.
Definition vec.h:58
yavl_vec_res_t status
Operation status (error code).
Definition vec.h:56
Type-agnostic vector definition.
Definition vec.h:86
size_t reservd
Currently reserved data.
Definition vec.h:102
size_t len
Current data length.
Definition vec.h:98
void * data
Pointer to data array.
Definition vec.h:91
size_t allign
Current data allignment (size of individual vector element in unsigned chars).
Definition vec.h:94