made popping with lists work. yay! (also new demo to show the thing)

This commit is contained in:
Odweta
2023-12-22 14:27:07 +01:00
parent ea527405e5
commit 45732c4b22
5 changed files with 47 additions and 14 deletions
+12
View File
@@ -106,3 +106,15 @@ listCleanup(list_t* l) {
vectorCleanup((vector_t *)l->data);
free(l);
}
void*
listPop(list_t* l) {
vector_t *first_ptr = (vector_t *)vectorPop((vector_t *)l->data);
void *ptr = vectorPop(first_ptr);
l->size -= 1;
if (l->size <= l->capacity / 2) l->capacity /= 2;
if (l->capacity == 0) l->capacity = 1;
return ptr;
}