diff --git a/src/meta/boxes.h b/src/meta/boxes.h index 38b0ecd4d..9a94ec5b9 100644 --- a/src/meta/boxes.h +++ b/src/meta/boxes.h @@ -63,3 +63,5 @@ struct _MetaEdge MetaSide side_type; MetaEdgeType edge_type; }; + +G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaStrut, g_free); diff --git a/src/tests/boxes-tests.c b/src/tests/boxes-tests.c index 12419dc4b..2a7d460b4 100644 --- a/src/tests/boxes-tests.c +++ b/src/tests/boxes-tests.c @@ -94,12 +94,6 @@ new_monitor_edge (int x, int y, int width, int height, int side_type) -static void -free_strut_list (GSList *struts) -{ - g_slist_free_full (struts, g_free); -} - static GSList* get_strut_list (int which) { @@ -149,8 +143,8 @@ get_strut_list (int which) static GList* get_screen_region (int which) { + g_autoslist (MetaStrut) struts = NULL; GList *ret; - GSList *struts; MtkRectangle basic_rect; basic_rect = MTK_RECTANGLE_INIT (0, 0, 1600, 1200); @@ -158,7 +152,6 @@ get_screen_region (int which) struts = get_strut_list (which); ret = meta_rectangle_get_minimal_spanning_set_for_region (&basic_rect, struts); - free_strut_list (struts); return ret; } @@ -166,8 +159,8 @@ get_screen_region (int which) static GList* get_screen_edges (int which) { + g_autoslist (MetaStrut) struts = NULL; GList *ret; - GSList *struts; MtkRectangle basic_rect; basic_rect = MTK_RECTANGLE_INIT (0, 0, 1600, 1200); @@ -175,7 +168,6 @@ get_screen_edges (int which) struts = get_strut_list (which); ret = meta_rectangle_find_onscreen_edges (&basic_rect, struts); - free_strut_list (struts); return ret; } @@ -183,8 +175,8 @@ get_screen_edges (int which) static GList* get_monitor_edges (int which_monitor_set, int which_strut_set) { + g_autoslist (MetaStrut) struts = NULL; GList *ret; - GSList *struts; GList *xins; xins = NULL; @@ -214,7 +206,6 @@ get_monitor_edges (int which_monitor_set, int which_strut_set) struts = get_strut_list (which_strut_set); ret = meta_rectangle_find_nonintersected_monitor_edges (xins, struts); - free_strut_list (struts); meta_rectangle_free_list_and_elements (xins); return ret; diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 443f40f28..119d8c2ba 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -1552,7 +1552,7 @@ meta_window_x11_move_resize_internal (MetaWindow *window, static gboolean meta_window_x11_update_struts (MetaWindow *window) { - GSList *old_struts; + g_autoslist (GSList) old_struts = NULL; GSList *new_struts; GSList *old_iter, *new_iter; uint32_t *struts = NULL; @@ -1564,7 +1564,7 @@ meta_window_x11_update_struts (MetaWindow *window) meta_verbose ("Updating struts for %s", window->desc); Window xwindow = meta_window_x11_get_xwindow (window); - old_struts = window->struts; + old_struts = g_steal_pointer (&window->struts); new_struts = NULL; if (meta_prop_get_cardinal_list (window->display->x11_display, @@ -1710,7 +1710,6 @@ meta_window_x11_update_struts (MetaWindow *window) changed = (old_iter != NULL || new_iter != NULL); /* Update appropriately */ - g_slist_free_full (old_struts, g_free); window->struts = new_struts; return changed; }