summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/list.c9
-rw-r--r--common/list.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/common/list.c b/common/list.c
index c6d8cb98..31ae9d35 100644
--- a/common/list.c
+++ b/common/list.c
@@ -99,6 +99,15 @@ struct slist *slist_find(struct slist *list, const void *data,
return NULL;
}
+void slist_foreach(struct slist *list, slist_func_t func, void *user_data)
+{
+ while (list) {
+ struct slist *next = list->next;
+ func(list->data, user_data);
+ list = next;
+ }
+}
+
void slist_free(struct slist *list)
{
struct slist *l, *next;
diff --git a/common/list.h b/common/list.h
index 1838370c..026d470c 100644
--- a/common/list.h
+++ b/common/list.h
@@ -31,6 +31,7 @@ struct slist {
};
typedef int (*cmp_func_t)(const void *a, const void *b);
+typedef void (*slist_func_t)(void *data, void *user_data);
struct slist *slist_append(struct slist *list, void *data);
@@ -39,6 +40,7 @@ struct slist *slist_remove(struct slist *list, void *data);
struct slist *slist_find(struct slist *list, const void *data,
cmp_func_t cmp_func);
+void slist_foreach(struct slist *list, slist_func_t func, void *user_data);
void slist_free(struct slist *list);
#endif /* __LIST_H */