From b892d2c21b1f1e84c0de0a10241a2ba9f7efc1f6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Wed, 9 Jul 2014 12:33:27 +0200 Subject: [PATCH] Clean up properly after X window is destroyed --- appwindow.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/appwindow.c b/appwindow.c index 9e1ff86..a849213 100644 --- a/appwindow.c +++ b/appwindow.c @@ -62,7 +62,7 @@ int append_window_text(char* text, int dont_flush) run_loop = 0; return ENOMEM; } - + window_text[window_text_count - 1] = (char*)malloc((strlen(text) + 1) * sizeof(char)); if (window_text[window_text_count - 1] == NULL) { fprintf(stderr, "CRITICAL: Insufficient memory to append text!\n"); @@ -142,9 +142,15 @@ int create_window() /** Destroys the window and cleans up */ void destroy_window() { + int idx; + XFreeGC(Xdisp, Xgc); XDestroyWindow(Xdisp, Xwin); XCloseDisplay(Xdisp); + + for (idx = 0; idx < window_text_count; idx++) + free(window_text[idx]); + free(window_text); } /** Manually flushes the drawing requests. -- 2.43.5