aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorprogandy <code@progandy>2015-12-22 15:35:37 +0100
committerprogandy <code@progandy>2015-12-22 17:54:47 +0100
commit8fefdb3c64d53a16bd400f97252c6887f5940af0 (patch)
tree95520c463d91e810fcad8b40b4cb219dfec2e871 /common
parentd060d0a39f977cf4e74fe3d9a747ee717ad733ba (diff)
downloadsway-8fefdb3c64d53a16bd400f97252c6887f5940af0.tar.xz
swaybar: fix memory leaks
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;