]> Devoid-pointer.net GitWeb - LFSBench.git/commitdiff
Clean up properly after X window is destroyed
authorMichal Malý <madcatxster@devoid-pointer.net>
Wed, 9 Jul 2014 10:33:27 +0000 (12:33 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Wed, 9 Jul 2014 10:33:27 +0000 (12:33 +0200)
appwindow.c

index 9e1ff862059d63a8f22fd0f123b7ae88e821f304..a8492130004dbc53975422d072bd3bd6f6a338d1 100644 (file)
@@ -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.