diff options
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/main.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/swaybar/main.c b/swaybar/main.c index a4b757a5..75d043b0 100644 --- a/swaybar/main.c +++ b/swaybar/main.c | |||
@@ -160,9 +160,21 @@ void cairo_set_source_u32(cairo_t *cairo, uint32_t color) { | |||
160 | (color & 0xFF) / 256.0); | 160 | (color & 0xFF) / 256.0); |
161 | } | 161 | } |
162 | 162 | ||
163 | void free_workspace(void *item) { | ||
164 | if (!item) { | ||
165 | return; | ||
166 | } | ||
167 | struct workspace *ws = (struct workspace *)item; | ||
168 | if (ws->name) { | ||
169 | free(ws->name); | ||
170 | } | ||
171 | free(ws); | ||
172 | } | ||
173 | |||
163 | void ipc_update_workspaces() { | 174 | void ipc_update_workspaces() { |
164 | if (workspaces) { | 175 | if (workspaces) { |
165 | free_flat_list(workspaces); | 176 | list_foreach(workspaces, free_workspace); |
177 | list_free(workspaces); | ||
166 | } | 178 | } |
167 | workspaces = create_list(); | 179 | workspaces = create_list(); |
168 | 180 | ||
@@ -456,6 +468,29 @@ void render() { | |||
456 | } | 468 | } |
457 | } | 469 | } |
458 | 470 | ||
471 | void free_status_block(void *item) { | ||
472 | if (!item) { | ||
473 | return; | ||
474 | } | ||
475 | struct status_block *sb = (struct status_block*)item; | ||
476 | if (sb->full_text) { | ||
477 | free(sb->full_text); | ||
478 | } | ||
479 | if (sb->short_text) { | ||
480 | free(sb->short_text); | ||
481 | } | ||
482 | if (sb->align) { | ||
483 | free(sb->align); | ||
484 | } | ||
485 | if (sb->name) { | ||
486 | free(sb->name); | ||
487 | } | ||
488 | if (sb->instance) { | ||
489 | free(sb->instance); | ||
490 | } | ||
491 | free(sb); | ||
492 | } | ||
493 | |||
459 | void parse_json(const char *text) { | 494 | void parse_json(const char *text) { |
460 | /* the array of objects looks like this: | 495 | /* the array of objects looks like this: |
461 | * [ { | 496 | * [ { |
@@ -484,7 +519,8 @@ void parse_json(const char *text) { | |||
484 | } | 519 | } |
485 | 520 | ||
486 | if (status_line) { | 521 | if (status_line) { |
487 | free_flat_list(status_line); | 522 | list_foreach(status_line, free_status_block); |
523 | list_free(status_line); | ||
488 | } | 524 | } |
489 | 525 | ||
490 | status_line = create_list(); | 526 | status_line = create_list(); |