list_insert now increases the length of the array correctly

This commit is contained in:
Sara 2023-11-04 20:41:17 +01:00
parent c9dcb508bd
commit 931a77b854

View file

@ -93,8 +93,6 @@ size_t list_add(List* self, void* item) {
}
void list_insert(List* self, void* item, size_t at) {
ASSERT_RETURN(at < self->len,, "Index %zu out of bounds", at);
list_reserve(self, self->len + 1);
if(at == self->len - 1) {
@ -113,6 +111,7 @@ void list_insert(List* self, void* item, size_t at) {
uint8_t* end = data.as_byte + self->element_size * self->len;
memmove(into, from, end - from);
memcpy(from, item, self->element_size);
++self->len;
}
void list_erase(List* self, size_t at) {