]> code.delx.au - spectrwm/commitdiff
Resolve memory leaks on exit
authorCampbell Barton <ideasman42@gmail.com>
Wed, 15 Apr 2015 13:51:29 +0000 (23:51 +1000)
committerReginald Kennedy <rk@rejii.com>
Sun, 19 Apr 2015 10:31:32 +0000 (18:31 +0800)
spectrwm.c

index 0e29167b06c353aadb07da09f9e5751ca1f76650..2cc0d246b0fe30f4ffc4a69a3027bdcccb5b87c7 100644 (file)
@@ -10827,6 +10827,7 @@ shutdown_cleanup(void)
 
        num_screens = get_screen_count();
        for (i = 0; i < num_screens; ++i) {
+               struct swm_region       *r;
                int j;
 
                xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT,
@@ -10846,19 +10847,39 @@ shutdown_cleanup(void)
                }
 
                for (j = 0; j < SWM_WS_MAX; ++j) {
+                       struct ws_win           *win;
+
                        free(screens[i].ws[j].name);
+
+                       while ((win = TAILQ_FIRST(&screens[i].ws[j].winlist)) != NULL) {
+                               TAILQ_REMOVE(&screens[i].ws[j].winlist, win, entry);
+                               free(win);
+                       }
+               }
+
+               while ((r = TAILQ_FIRST(&screens[i].rl)) != NULL) {
+                       TAILQ_REMOVE(&screens[i].rl, r, entry);
+                       free(r->bar);
+                       free(r);
+               }
+
+               while ((r = TAILQ_FIRST(&screens[i].orl)) != NULL) {
+                       TAILQ_REMOVE(&screens[i].rl, r, entry);
+                       free(r->bar);
+                       free(r);
                }
        }
        free(screens);
 
        free(bar_format);
+       free(bar_fonts);
        free(clock_format);
+       free(startup_exception);
 
-       if (bar_font_legacy)
+       if (bar_fs)
                XFreeFontSet(display, bar_fs);
-       else {
+       if (bar_font_legacy == false)
                XftFontClose(display, bar_font);
-       }
 
        xcb_key_symbols_free(syms);
        xcb_flush(conn);