diff options
Diffstat (limited to 'lib/list')
| -rw-r--r-- | lib/list/list.c | 14 | ||||
| -rw-r--r-- | lib/list/list.h | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/list/list.c b/lib/list/list.c index 753fdb1..8064da4 100644 --- a/lib/list/list.c +++ b/lib/list/list.c @@ -28,6 +28,20 @@ list_t *from_array(void **array, u64 size) } +void free_list(list_t *list) +{ + list_node_t *node = list->first; + list_node_t *next; + free(list); + + while (node) { + next = node->next; + free(node); + node = next; + } +} + + void list_append(list_t *list, void *value) { list_node_t *node = __new_list_node(value); diff --git a/lib/list/list.h b/lib/list/list.h index 9acecac..2021b2a 100644 --- a/lib/list/list.h +++ b/lib/list/list.h @@ -21,6 +21,6 @@ void list_append(list_t *list, void *value); void list_prepend(list_t *list, void *value); void *pop_first(list_t *list); void *pop_last(list_t *list); -void free_list(); +void free_list(list_t *list); #endif |