From 931a77b8546a058c8b31ff944a1d1d10b792456f Mon Sep 17 00:00:00 2001 From: Sara <sara@saragerretsen.nl> Date: Sat, 4 Nov 2023 20:41:17 +0100 Subject: [PATCH] list_insert now increases the length of the array correctly --- src/list.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/list.c b/src/list.c index acba56a..cca816e 100644 --- a/src/list.c +++ b/src/list.c @@ -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) {