diff --git a/lib/array_list.c b/lib/array_list.c index 194060e..5733c64 100644 --- a/lib/array_list.c +++ b/lib/array_list.c @@ -37,3 +37,8 @@ void* array_list_get(struct array_list* list, size_t index) { } return list->data[index]; } + +void array_list_free(struct array_list* list) { + free(list->data); + free(list); +} diff --git a/lib/array_list.h b/lib/array_list.h index 7279d5d..1c96b9e 100644 --- a/lib/array_list.h +++ b/lib/array_list.h @@ -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); +/** + * @brief Frees the array list. + * @since v2.1.0 + */ +void array_list_free(struct array_list* list); + #endif diff --git a/test/array_list_test.c b/test/array_list_test.c index 0366f23..9c1b4a6 100644 --- a/test/array_list_test.c +++ b/test/array_list_test.c @@ -32,4 +32,6 @@ void array_list_test() { array_list_remove(list, 100); assert(list->size == 105); assert(array_list_get(list, 100) == (void *)95); + + array_list_free(list); }