mirror of
https://github.com/theoludwig/libcproject.git
synced 2024-11-13 23:43:13 +01:00
feat: add array_list_free
This commit is contained in:
parent
2796dec0c7
commit
d231a0f055
@ -37,3 +37,8 @@ void* array_list_get(struct array_list* list, size_t index) {
|
|||||||
}
|
}
|
||||||
return list->data[index];
|
return list->data[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void array_list_free(struct array_list* list) {
|
||||||
|
free(list->data);
|
||||||
|
free(list);
|
||||||
|
}
|
||||||
|
@ -42,4 +42,10 @@ void array_list_remove(struct array_list* list, size_t index);
|
|||||||
*/
|
*/
|
||||||
void* array_list_get(struct array_list* list, size_t index);
|
void* array_list_get(struct array_list* list, size_t index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Frees the array list.
|
||||||
|
* @since v2.1.0
|
||||||
|
*/
|
||||||
|
void array_list_free(struct array_list* list);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,4 +32,6 @@ void array_list_test() {
|
|||||||
array_list_remove(list, 100);
|
array_list_remove(list, 100);
|
||||||
assert(list->size == 105);
|
assert(list->size == 105);
|
||||||
assert(array_list_get(list, 100) == (void *)95);
|
assert(array_list_get(list, 100) == (void *)95);
|
||||||
|
|
||||||
|
array_list_free(list);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user