feat: added list_set_len

to set the length of the array
main
Sara 2024-01-26 11:49:49 +01:00
parent fa10d64aee
commit b38362c2aa
2 changed files with 6 additions and 0 deletions

5
list.c
View File

@ -64,6 +64,11 @@ void list_reserve(List* self, size_t at_least) {
self->cap = new_cap;
}
void list_set_len(List* self, size_t len) {
list_reserve(self, len);
self->len = len;
}
void* list_at_unchecked(List* self, size_t at) {
union {
uint8_t* as_byte;

1
list.h
View File

@ -17,6 +17,7 @@ extern List list_copy(const List* source);
extern void list_empty(List* list);
extern void list_reserve(List* self, size_t at_least);
extern void list_set_len(List* self, size_t len);
extern void* list_at(List* list, size_t at);
extern void* list_at_unchecked(List* self, size_t at);