1
1
mirror of https://github.com/theoludwig/libcproject.git synced 2024-11-08 22:31:31 +01:00

feat: add array_list_free

This commit is contained in:
Théo LUDWIG 2023-08-03 19:42:50 +02:00
parent 2796dec0c7
commit d231a0f055
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
3 changed files with 13 additions and 0 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}