Use free_full on GSList's instead of foreach + free
GList's used in legacy code were free'd using a g_slist_foreach + g_slist_free, while we can just use g_slist_free_full as per GLib 2.28. So replace code where we were using this legacy codepath. https://gitlab.gnome.org/GNOME/mutter/merge_requests/576
This commit is contained in:
parent
df7d8e2cbf
commit
7a17e236f7
@ -235,8 +235,7 @@ clutter_binding_pool_finalize (GObject *gobject)
|
||||
|
||||
g_hash_table_destroy (pool->entries_hash);
|
||||
|
||||
g_slist_foreach (pool->entries, (GFunc) binding_entry_free, NULL);
|
||||
g_slist_free (pool->entries);
|
||||
g_slist_free_full (pool->entries, (GDestroyNotify) binding_entry_free);
|
||||
|
||||
G_OBJECT_CLASS (clutter_binding_pool_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
@ -412,8 +412,7 @@ master_clock_advance_timelines (ClutterMasterClockDefault *master_clock)
|
||||
for (l = timelines; l != NULL; l = l->next)
|
||||
_clutter_timeline_do_tick (l->data, master_clock->cur_tick / 1000);
|
||||
|
||||
g_slist_foreach (timelines, (GFunc) g_object_unref, NULL);
|
||||
g_slist_free (timelines);
|
||||
g_slist_free_full (timelines, g_object_unref);
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
if (_clutter_diagnostic_enabled ())
|
||||
@ -574,8 +573,7 @@ clutter_clock_dispatch (GSource *source,
|
||||
|
||||
master_clock_reschedule_stage_updates (master_clock, stages);
|
||||
|
||||
g_slist_foreach (stages, (GFunc) g_object_unref, NULL);
|
||||
g_slist_free (stages);
|
||||
g_slist_free_full (stages, g_object_unref);
|
||||
|
||||
master_clock->prev_tick = master_clock->cur_tick;
|
||||
|
||||
|
@ -295,8 +295,7 @@ clutter_path_clear (ClutterPath *path)
|
||||
{
|
||||
ClutterPathPrivate *priv = path->priv;
|
||||
|
||||
g_slist_foreach (priv->nodes, (GFunc) clutter_path_node_full_free, NULL);
|
||||
g_slist_free (priv->nodes);
|
||||
g_slist_free_full (priv->nodes, (GDestroyNotify) clutter_path_node_full_free);
|
||||
|
||||
priv->nodes = priv->nodes_tail = NULL;
|
||||
priv->nodes_dirty = TRUE;
|
||||
@ -659,8 +658,7 @@ clutter_path_parse_description (const gchar *p,
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
g_slist_foreach (nodes, (GFunc) clutter_path_node_full_free, NULL);
|
||||
g_slist_free (nodes);
|
||||
g_slist_free_full (nodes, (GDestroyNotify) clutter_path_node_full_free);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -843,8 +843,7 @@ clutter_script_unmerge_objects (ClutterScript *script,
|
||||
for (l = data.ids; l != NULL; l = l->next)
|
||||
g_hash_table_remove (priv->objects, l->data);
|
||||
|
||||
g_slist_foreach (data.ids, (GFunc) g_free, NULL);
|
||||
g_slist_free (data.ids);
|
||||
g_slist_free_full (data.ids, g_free);
|
||||
|
||||
clutter_script_ensure_objects (script);
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ clutter_stage_manager_dispose (GObject *gobject)
|
||||
|
||||
stage_manager = CLUTTER_STAGE_MANAGER (gobject);
|
||||
|
||||
g_slist_foreach (stage_manager->stages, (GFunc) clutter_actor_destroy, NULL);
|
||||
g_slist_free (stage_manager->stages);
|
||||
g_slist_free_full (stage_manager->stages,
|
||||
(GDestroyNotify) clutter_actor_destroy);
|
||||
stage_manager->stages = NULL;
|
||||
|
||||
G_OBJECT_CLASS (clutter_stage_manager_parent_class)->dispose (gobject);
|
||||
|
@ -38,8 +38,7 @@ timeline_data_init (TimelineData *data, int timeline_num)
|
||||
static void
|
||||
timeline_data_destroy (TimelineData *data)
|
||||
{
|
||||
g_slist_foreach (data->markers_hit, (GFunc) g_free, NULL);
|
||||
g_slist_free (data->markers_hit);
|
||||
g_slist_free_full (data->markers_hit, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -483,8 +483,8 @@ _cogl_pango_display_list_node_free (CoglPangoDisplayListNode *node)
|
||||
void
|
||||
_cogl_pango_display_list_clear (CoglPangoDisplayList *dl)
|
||||
{
|
||||
g_slist_foreach (dl->nodes, (GFunc) _cogl_pango_display_list_node_free, NULL);
|
||||
g_slist_free (dl->nodes);
|
||||
g_slist_free_full (dl->nodes, (GDestroyNotify)
|
||||
_cogl_pango_display_list_node_free);
|
||||
dl->nodes = NULL;
|
||||
dl->last_node = NULL;
|
||||
}
|
||||
|
@ -194,10 +194,8 @@ _cogl_renderer_free (CoglRenderer *renderer)
|
||||
if (renderer->libgl_module)
|
||||
g_module_close (renderer->libgl_module);
|
||||
|
||||
g_slist_foreach (renderer->event_filters,
|
||||
(GFunc) native_filter_closure_free,
|
||||
NULL);
|
||||
g_slist_free (renderer->event_filters);
|
||||
g_slist_free_full (renderer->event_filters,
|
||||
(GDestroyNotify) native_filter_closure_free);
|
||||
|
||||
g_array_free (renderer->poll_fds, TRUE);
|
||||
|
||||
|
@ -59,10 +59,8 @@ _cogl_program_free (CoglProgram *program)
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
/* Unref all of the attached shaders */
|
||||
g_slist_foreach (program->attached_shaders, (GFunc) cogl_handle_unref, NULL);
|
||||
/* Destroy the list */
|
||||
g_slist_free (program->attached_shaders);
|
||||
/* Unref all of the attached shaders and destroy the list */
|
||||
g_slist_free_full (program->attached_shaders, cogl_handle_unref);
|
||||
|
||||
for (i = 0; i < program->custom_uniforms->len; i++)
|
||||
{
|
||||
|
@ -1157,13 +1157,7 @@ compute_resistance_and_snapping_edges (MetaDisplay *display)
|
||||
g_list_free (stacked_windows);
|
||||
/* Free the memory used by the obscuring windows/docks lists */
|
||||
g_slist_free (window_stacking);
|
||||
/* FIXME: Shouldn't there be a helper function to make this one line of code
|
||||
* to free a list instead of four ugly ones?
|
||||
*/
|
||||
g_slist_foreach (obscuring_windows,
|
||||
(void (*)(gpointer,gpointer))&g_free, /* ew, for ugly */
|
||||
NULL);
|
||||
g_slist_free (obscuring_windows);
|
||||
g_slist_free_full (obscuring_windows, g_free);
|
||||
|
||||
/* Sort the list. FIXME: Should I bother with this sorting? I just
|
||||
* sort again later in cache_edges() anyway...
|
||||
|
@ -575,8 +575,7 @@ meta_startup_notification_finalize (GObject *object)
|
||||
if (sn->startup_sequence_timeout)
|
||||
g_source_remove (sn->startup_sequence_timeout);
|
||||
|
||||
g_slist_foreach (sn->startup_sequences, (GFunc) g_object_unref, NULL);
|
||||
g_slist_free (sn->startup_sequences);
|
||||
g_slist_free_full (sn->startup_sequences, g_object_unref);
|
||||
sn->startup_sequences = NULL;
|
||||
|
||||
G_OBJECT_CLASS (meta_startup_notification_parent_class)->finalize (object);
|
||||
|
@ -249,10 +249,7 @@ utf8_fputs (const char *str,
|
||||
void
|
||||
meta_free_gslist_and_elements (GSList *list_to_deep_free)
|
||||
{
|
||||
g_slist_foreach (list_to_deep_free,
|
||||
(void (*)(gpointer,gpointer))&g_free, /* ew, for ugly */
|
||||
NULL);
|
||||
g_slist_free (list_to_deep_free);
|
||||
g_slist_free_full (list_to_deep_free, g_free);
|
||||
}
|
||||
|
||||
#ifdef WITH_VERBOSE_MODE
|
||||
|
@ -52,8 +52,6 @@ void meta_workspace_queue_calc_showing (MetaWorkspace *workspace);
|
||||
static void focus_ancestor_or_top_window (MetaWorkspace *workspace,
|
||||
MetaWindow *not_this_one,
|
||||
guint32 timestamp);
|
||||
static void free_this (gpointer candidate,
|
||||
gpointer dummy);
|
||||
|
||||
G_DEFINE_TYPE (MetaWorkspace, meta_workspace, G_TYPE_OBJECT);
|
||||
|
||||
@ -265,13 +263,6 @@ meta_workspace_new (MetaWorkspaceManager *workspace_manager)
|
||||
return workspace;
|
||||
}
|
||||
|
||||
/* Foreach function for workspace_free_struts() */
|
||||
static void
|
||||
free_this (gpointer candidate, gpointer dummy)
|
||||
{
|
||||
g_free (candidate);
|
||||
}
|
||||
|
||||
/**
|
||||
* workspace_free_all_struts:
|
||||
* @workspace: The workspace.
|
||||
@ -284,8 +275,7 @@ workspace_free_all_struts (MetaWorkspace *workspace)
|
||||
if (workspace->all_struts == NULL)
|
||||
return;
|
||||
|
||||
g_slist_foreach (workspace->all_struts, free_this, NULL);
|
||||
g_slist_free (workspace->all_struts);
|
||||
g_slist_free_full (workspace->all_struts, g_free);
|
||||
workspace->all_struts = NULL;
|
||||
}
|
||||
|
||||
@ -301,8 +291,7 @@ workspace_free_builtin_struts (MetaWorkspace *workspace)
|
||||
if (workspace->builtin_struts == NULL)
|
||||
return;
|
||||
|
||||
g_slist_foreach (workspace->builtin_struts, free_this, NULL);
|
||||
g_slist_free (workspace->builtin_struts);
|
||||
g_slist_free_full (workspace->builtin_struts, g_free);
|
||||
workspace->builtin_struts = NULL;
|
||||
}
|
||||
|
||||
|
@ -221,13 +221,7 @@ test_basic_fitting (void)
|
||||
static void
|
||||
free_strut_list (GSList *struts)
|
||||
{
|
||||
GSList *tmp = struts;
|
||||
while (tmp)
|
||||
{
|
||||
g_free (tmp->data);
|
||||
tmp = tmp->next;
|
||||
}
|
||||
g_slist_free (struts);
|
||||
g_slist_free_full (struts, g_free);
|
||||
}
|
||||
|
||||
static GSList*
|
||||
|
Loading…
Reference in New Issue
Block a user