Make VEC_GET take an index along with the type

Since most use cases require indexing the data directly, and the macro
implies you're retrieving data from it, may as well take the index.

If you wanted a pointer to that data, &VEC_GET(vec, index, type) works
just fine.
This commit is contained in:
2026-01-21 09:48:29 +00:00
parent 8c190e955d
commit 865ab22fdc
3 changed files with 9 additions and 9 deletions

View File

@@ -76,8 +76,8 @@ typedef struct Vector
static_assert(sizeof(vec_t) == 64, "vec_t has to be 64 bytes as part of SBO");
#define VEC_GET(V, T) ((T *)vec_data(V))
#define VEC_SIZE(V, T) ((V)->size / (sizeof(T)))
#define VEC_GET(V, I, T) (((T *)vec_data(V))[I])
#define VEC_SIZE(V, T) ((V)->size / (sizeof(T)))
void vec_init(vec_t *, u64);
void vec_free(vec_t *);