]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Correctly free containers when shrinking the table
authorMichael Stapelberg <michael+x200@stapelberg.de>
Mon, 9 Mar 2009 05:49:11 +0000 (06:49 +0100)
committerMichael Stapelberg <michael+x200@stapelberg.de>
Mon, 9 Mar 2009 05:49:11 +0000 (06:49 +0100)
src/table.c

index fe50438e1b466ddb1899cf6882e1e85216d97282..91aabbac554c4120cc8f61395067990d0aae45ed 100644 (file)
@@ -87,14 +87,24 @@ void expand_table_cols(Workspace *workspace) {
 
 static void shrink_table_cols(Workspace *workspace) {
         workspace->cols--;
+
+        /* Free the containers */
+        for (int rows = 0; rows < workspace->rows; rows++)
+                free(workspace->table[workspace->cols][rows]);
+
+        /* Free the container-pointers */
         free(workspace->table[workspace->cols]);
+
+        /* Re-allocate the table */
         workspace->table = realloc(workspace->table, sizeof(Container**) * workspace->cols);
 }
 
 static void shrink_table_rows(Workspace *workspace) {
         workspace->rows--;
-        for (int cols = 0; cols < workspace->cols; cols++)
+        for (int cols = 0; cols < workspace->cols; cols++) {
+                free(workspace->table[cols][workspace->rows]);
                 workspace->table[cols] = realloc(workspace->table[cols], sizeof(Container*) * workspace->rows);
+        }
 }