fix(lib): silence warnings with -Wpedantic

This commit is contained in:
Amaan Qureshi 2024-09-27 12:19:42 -04:00
parent 0c43988a5e
commit 28972f916a
9 changed files with 62 additions and 52 deletions

View file

@ -6,8 +6,8 @@ extern "C" {
#endif
#include "./alloc.h"
#include "./ts_assert.h"
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
@ -37,7 +37,7 @@ extern "C" {
/// Get a pointer to the element at a given `index` in the array.
#define array_get(self, _index) \
(assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index])
(ts_assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index])
/// Get a pointer to the first element in the array.
#define array_front(self) array_get(self, 0)
@ -171,7 +171,7 @@ static inline void _array__delete(Array *self) {
/// This is not what you're looking for, see `array_erase`.
static inline void _array__erase(Array *self, size_t element_size,
uint32_t index) {
assert(index < self->size);
ts_assert(index < self->size);
char *contents = (char *)self->contents;
memmove(contents + index * element_size, contents + (index + 1) * element_size,
(self->size - index - 1) * element_size);
@ -222,7 +222,7 @@ static inline void _array__splice(Array *self, size_t element_size,
uint32_t new_size = self->size + new_count - old_count;
uint32_t old_end = index + old_count;
uint32_t new_end = index + new_count;
assert(old_end <= self->size);
ts_assert(old_end <= self->size);
_array__reserve(self, element_size, new_size);