mirror of
https://github.com/theoludwig/libcproject.git
synced 2025-05-21 23:21:15 +02:00
feat: add linked_list_free
This commit is contained in:
@ -84,3 +84,13 @@ void linked_list_reverse_mutate(struct linked_list *list) {
|
||||
(*current) = temporary_current;
|
||||
}
|
||||
}
|
||||
|
||||
void linked_list_free(struct linked_list *list) {
|
||||
struct linked_list_node *node_current = list->head;
|
||||
while (node_current != NULL) {
|
||||
struct linked_list_node *node_to_remove = node_current;
|
||||
node_current = node_current->next;
|
||||
free(node_to_remove);
|
||||
}
|
||||
free(list);
|
||||
}
|
||||
|
@ -62,4 +62,10 @@ struct linked_list *linked_list_reverse(struct linked_list *list);
|
||||
*/
|
||||
void linked_list_reverse_mutate(struct linked_list *list);
|
||||
|
||||
/**
|
||||
* @brief Free the linked list.
|
||||
* @since v2.1.0
|
||||
*/
|
||||
void linked_list_free(struct linked_list *list);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user