bounds checked arrays

This commit is contained in:
2025-12-13 16:47:40 +01:00
parent 289f4bb371
commit 8485ad25e4
3 changed files with 90 additions and 0 deletions
+8
View File
@@ -180,6 +180,14 @@ size_t arr_cap(void *this);
#define arr_pop(THIS) (arr_shrink(THIS, 1), THIS[arr_len(THIS)])
void dyn_array_bounds_check_func(void *this, size_t index, const char *file, int line);
#define arr_get(THIS, INDEX) \
(dyn_array_bounds_check_func(THIS, INDEX, __FILE__, __LINE__), (THIS)[INDEX])
#define arr_set(THIS, INDEX, VALUE) \
(dyn_array_bounds_check_func(THIS, INDEX, __FILE__, __LINE__), (THIS)[INDEX] = (VALUE))
#define STATIC_ASSERT(expr) ((void)sizeof(char[(expr) ? 1 : -1]))
bool dyn_array_contains_func(void *this, uint8_t *value);