list_insert now increases the length of the array correctly
This commit is contained in:
parent
c9dcb508bd
commit
931a77b854
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue