|
YAVL 0.1.0
Yet Another Vector Library – still better than C++ impl. :P
|
#include <stddef.h>#include <stdbool.h>Go to the source code of this file.
Classes | |
| struct | yavl_vec_t |
| Type-agnostic vector definition. More... | |
| struct | yavl_vec_errorable_t |
| A return package which contains both result code and data. More... | |
Macros | |
| #define | YAVL_VEC_T_ALLOCATOR ((yavl_vec_t){}) |
| Allocator for yavl_vec_t. | |
Enumerations | |
| enum | yavl_vec_res_t : char { YAVL_VEC_RES_OOM = -2 , YAVL_VEC_RES_NULL , YAVL_VEC_RES_OK = 0 , YAVL_VEC_RES_FAIL } |
| Operation result codes. More... | |
Functions | |
| yavl_vec_res_t | yavl_vec_init (yavl_vec_t *const memory, size_t data_align, size_t data_reserv) |
| Initializes a new vector. Frees memory if it is already allocated. | |
| yavl_vec_res_t | yavl_vec_push (yavl_vec_t *const vec, const void *const data) |
| Pushes data to vector. | |
| yavl_vec_errorable_t | yavl_vec_pop (yavl_vec_t *const vec) |
| Pops last elements out of vector. Doesn't free memory yet. | |
| 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_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_get (yavl_vec_t *const vec, size_t offset, void *const out) |
| Gets element at offset and stores it in out memory. | |
| yavl_vec_errorable_t | yavl_vec_ref (yavl_vec_t *const vec) |
| Get reference to dynamic vector array. | |
| yavl_vec_res_t | yavl_vec_free (yavl_vec_t *const vec) |
| Frees heap in vector and zeroes the entire object. | |
| 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 freshness of the ptr and protect it against out-of-memory-bounds scenarios. | |
| yavl_vec_errorable_t | yavl_vec_flush (yavl_vec_t *const vec) |
| Finalizes vector, to result it in statically-sized array. This allows you to drop vector metadata. | |
Vector public API definition
SPDX-License: GPL-3.0-or-later
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.