aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-12-22 12:19:51 -0500
committerDrew DeVault <sir@cmpwn.com>2015-12-22 12:19:51 -0500
commit27848b41ab9552b7894bdd32c3cdaa490a864446 (patch)
treec4d102502cdf6cbab906acf1535f341ec188202b /common
parent8a22ac3966047353daffe88dd4b8c2910ef519f5 (diff)
parent8fefdb3c64d53a16bd400f97252c6887f5940af0 (diff)
Merge pull request #394 from progandy/i3bar-json-protocol
swaybar: I3bar json protocol
Diffstat (limited to 'common')
-rw-r--r--common/list.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/common/list.c b/common/list.c
index 850c8569..a7585a31 100644
--- a/common/list.c
+++ b/common/list.c
@@ -26,6 +26,15 @@ 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;