diff options
Diffstat (limited to 'common/list.c')
-rw-r--r-- | common/list.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/common/list.c b/common/list.c index ee268c9a..a0b42512 100644 --- a/common/list.c +++ b/common/list.c | |||
@@ -30,15 +30,6 @@ void list_free(list_t *list) { | |||
30 | free(list); | 30 | free(list); |
31 | } | 31 | } |
32 | 32 | ||
33 | void list_foreach(list_t *list, void (*callback)(void *item)) { | ||
34 | if (list == NULL || callback == NULL) { | ||
35 | return; | ||
36 | } | ||
37 | for (int i = 0; i < list->length; i++) { | ||
38 | callback(list->items[i]); | ||
39 | } | ||
40 | } | ||
41 | |||
42 | void list_add(list_t *list, void *item) { | 33 | void list_add(list_t *list, void *item) { |
43 | list_resize(list); | 34 | list_resize(list); |
44 | list->items[list->length++] = item; | 35 | list->items[list->length++] = item; |
@@ -156,3 +147,15 @@ void list_stable_sort(list_t *list, int compare(const void *a, const void *b)) { | |||
156 | list_inplace_sort(list, 0, list->length - 1, compare); | 147 | list_inplace_sort(list, 0, list->length - 1, compare); |
157 | } | 148 | } |
158 | } | 149 | } |
150 | |||
151 | void free_flat_list(list_t *list) { | ||
152 | if (!list) { | ||
153 | return; | ||
154 | } | ||
155 | |||
156 | for (int i = 0; i < list->length; ++i) { | ||
157 | free(list->items[i]); | ||
158 | } | ||
159 | list_free(list); | ||
160 | } | ||
161 | |||