prick_vec: PRICK_SHORTHAND quality of life feature

A little QoL feature implemented as a preprocesser flag, where we
provide macros without the `prick_` prefix that link to the prick_vec
functions.
This commit is contained in:
2026-03-17 20:30:03 +00:00
parent 277606d483
commit 8a3ae735dc

View File

@@ -9,6 +9,11 @@
#include "prick_vec.h" #include "prick_vec.h"
in one of your code units. in one of your code units.
To remove the `prick_` namespacing, please put:
#define PRICK_SHORTHAND
in any files before including prick_vec.h. Standard preprocesser rules apply
with regards to hierarchy.
This library defines another form of dynamically sized array as opposed to This library defines another form of dynamically sized array as opposed to
prick_darr.h. This one is closer to the one classically implemented by most; a prick_darr.h. This one is closer to the one classically implemented by most; a
structure with some metadata and a pointer to the raw buffer. This way, structure with some metadata and a pointer to the raw buffer. This way,
@@ -184,6 +189,22 @@ size_t prick_vec_find(prick_vec_t *vec, void *ptr, size_t ptrsize)
#undef MAX #undef MAX
#endif #endif
#ifdef PRICK_SHORTHAND
typedef prick_vec_t vec_t;
#define vec_append prick_vec_append
#define vec_append_byte prick_vec_append_byte
#define vec_data prick_vec_data
#define vec_ensure_capacity prick_vec_ensure_capacity
#define vec_ensure_free prick_vec_ensure_free
#define vec_free prick_vec_free
#define vec_clone prick_vec_clone
#define vec_pop prick_vec_pop
#define vec_find prick_vec_find
#define VEC_GET PRICK_VEC_GET
#endif
#endif #endif
/* Copyright (C) 2026 Aryadev Chavali /* Copyright (C) 2026 Aryadev Chavali