From: Michael Stapelberg Date: Mon, 9 Mar 2009 05:49:11 +0000 (+0100) Subject: Bugfix: Correctly free containers when shrinking the table X-Git-Tag: 3.a~54 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2cf3a9dd96eb0caa2546be79a0e8af21773b1c75;p=i3%2Fi3 Bugfix: Correctly free containers when shrinking the table --- diff --git a/src/table.c b/src/table.c index fe50438e..91aabbac 100644 --- a/src/table.c +++ b/src/table.c @@ -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); + } }