mirror of
https://github.com/swaywm/sway.git
synced 2025-04-03 19:07:45 +03:00
swaybar: fix memory leaks
This commit is contained in:
parent
d060d0a39f
commit
8fefdb3c64
3 changed files with 48 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue