list.c: Remove list_foreach

Most occurrences have been replaced by `free_flat_list` which has been
moved from stringop.c to list.c. The rest have been replaced by for loops.
This commit is contained in:
Ian Fan 2018-12-08 22:52:29 +00:00
parent 0c3f0dfd16
commit 19e831ed3d
11 changed files with 39 additions and 55 deletions

View file

@ -30,15 +30,6 @@ void list_free(list_t *list) {
free(list);
}
void list_foreach(list_t *list, void (*callback)(void *item)) {
if (list == NULL || callback == NULL) {
return;
}
for (int i = 0; i < list->length; i++) {
callback(list->items[i]);
}
}
void list_add(list_t *list, void *item) {
list_resize(list);
list->items[list->length++] = item;
@ -156,3 +147,15 @@ void list_stable_sort(list_t *list, int compare(const void *a, const void *b)) {
list_inplace_sort(list, 0, list->length - 1, compare);
}
}
void free_flat_list(list_t *list) {
if (!list) {
return;
}
for (int i = 0; i < list->length; ++i) {
free(list->items[i]);
}
list_free(list);
}