diff options
author | 2015-12-22 12:19:51 -0500 | |
---|---|---|
committer | 2015-12-22 12:19:51 -0500 | |
commit | 27848b41ab9552b7894bdd32c3cdaa490a864446 (patch) | |
tree | c4d102502cdf6cbab906acf1535f341ec188202b /common/list.c | |
parent | Initialize id, part two (diff) | |
parent | swaybar: fix memory leaks (diff) | |
download | sway-27848b41ab9552b7894bdd32c3cdaa490a864446.tar.gz sway-27848b41ab9552b7894bdd32c3cdaa490a864446.tar.zst sway-27848b41ab9552b7894bdd32c3cdaa490a864446.zip |
Merge pull request #394 from progandy/i3bar-json-protocol
swaybar: I3bar json protocol
Diffstat (limited to 'common/list.c')
-rw-r--r-- | common/list.c | 9 |
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) { | |||
26 | free(list); | 26 | free(list); |
27 | } | 27 | } |
28 | 28 | ||
29 | void list_foreach(list_t *list, void (*callback)(void *item)) { | ||
30 | if (list == NULL || callback == NULL) { | ||
31 | return; | ||
32 | } | ||
33 | for (int i = 0; i < list->length; i++) { | ||
34 | callback(list->items[i]); | ||
35 | } | ||
36 | } | ||
37 | |||
29 | void list_add(list_t *list, void *item) { | 38 | void list_add(list_t *list, void *item) { |
30 | list_resize(list); | 39 | list_resize(list); |
31 | list->items[list->length++] = item; | 40 | list->items[list->length++] = item; |