diff options
author | Thomas Thurman <tthurman@gnome.org> | 2008-09-22 15:36:53 +0000 |
---|---|---|
committer | Thomas James Alexander Thurman <tthurman@src.gnome.org> | 2008-09-22 15:36:53 +0000 |
commit | b30af2c1ce8d0cd026ea24674c0db14ffa31b84f (patch) | |
tree | c25e130f53ab997ce719ba04a675e01377dfbc15 | |
parent | b81efb1d9f1adc1338e31dfbb6c3bcd381ee5e19 (diff) | |
download | metacity-b30af2c1ce8d0cd026ea24674c0db14ffa31b84f.tar.gz |
Fix small memory leak found by Matthias Clasen which was in trunk but not
2008-09-22 Thomas Thurman <tthurman@gnome.org>
* src/core/workspace.c: Fix small memory leak
found by Matthias Clasen which was in trunk but
not stable. (#549952)
svn path=/branches/gnome-2-24/; revision=3920
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/core/workspace.c | 31 |
2 files changed, 34 insertions, 3 deletions
@@ -1,3 +1,9 @@ +2008-09-22 Thomas Thurman <tthurman@gnome.org> + + * src/core/workspace.c: Fix small memory leak + found by Matthias Clasen which was in trunk but + not stable. (#549952) + 2008-09-09 Thomas Thurman <tthurman@gnome.org> * configure.in: Post-release bump to 2.23.987. diff --git a/src/core/workspace.c b/src/core/workspace.c index 13731d57..ddb2541f 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -35,6 +35,9 @@ static void set_active_space_hint (MetaScreen *screen); static void focus_ancestor_or_mru_window (MetaWorkspace *workspace, MetaWindow *not_this_one, guint32 timestamp); +static void free_this (gpointer candidate, + gpointer dummy); +static void workspace_free_struts (MetaWorkspace *workspace); static void maybe_add_to_list (MetaScreen *screen, MetaWindow *window, gpointer data) @@ -79,6 +82,29 @@ meta_workspace_new (MetaScreen *screen) return workspace; } +/** Foreach function for workspace_free_struts() */ +static void +free_this (gpointer candidate, gpointer dummy) +{ + g_free (candidate); +} + +/** + * Frees the struts list of a workspace. + * + * \param workspace The workspace. + */ +static void +workspace_free_struts (MetaWorkspace *workspace) +{ + if (workspace->all_struts == NULL) + return; + + g_slist_foreach (workspace->all_struts, free_this, NULL); + g_slist_free (workspace->all_struts); + workspace->all_struts = NULL; +} + void meta_workspace_free (MetaWorkspace *workspace) { @@ -127,7 +153,7 @@ meta_workspace_free (MetaWorkspace *workspace) if (!workspace->work_areas_invalid) { - g_slist_free (workspace->all_struts); + workspace_free_struts (workspace); for (i = 0; i < screen->n_xinerama_infos; i++) meta_rectangle_free_list_and_elements (workspace->xinerama_region[i]); g_free (workspace->xinerama_region); @@ -457,8 +483,7 @@ meta_workspace_invalidate_work_area (MetaWorkspace *workspace) g_free (workspace->work_area_xinerama); workspace->work_area_xinerama = NULL; - g_slist_free (workspace->all_struts); - workspace->all_struts = NULL; + workspace_free_struts (workspace); for (i = 0; i < workspace->screen->n_xinerama_infos; i++) meta_rectangle_free_list_and_elements (workspace->xinerama_region[i]); |