From: Michal MalĂ˝ Date: Wed, 9 Jul 2014 10:33:27 +0000 (+0200) Subject: Clean up properly after X window is destroyed X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=b892d2c21b1f1e84c0de0a10241a2ba9f7efc1f6;p=LFSBench.git Clean up properly after X window is destroyed --- 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.