swaybar: fix memory leaks

This commit is contained in:
progandy 2015-12-22 15:35:37 +01:00
parent d060d0a39f
commit 8fefdb3c64
3 changed files with 48 additions and 2 deletions

View file

@ -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;