Skip to content

Commit

Permalink
Replace some GLib wrappers (#421)
Browse files Browse the repository at this point in the history
* Replace g_malloc with malloc

* Replace g_realloc* with realloc

* Replace g_free with free

g_free is just a simple wrapper around free(), with a custom debug macro
appended. Considering the performance impact of this extra function that
is used everywhere, it is worth using the standard free.

* Replace g_malloc0 with calloc

* Include stdlib.h

Only LMDE needs this for some reason.

* Fix up rebase
  • Loading branch information
jaszhix authored and clefebvre committed Apr 13, 2019
1 parent 8e3c602 commit 317c06f
Show file tree
Hide file tree
Showing 239 changed files with 3,113 additions and 3,111 deletions.
8 changes: 4 additions & 4 deletions clutter/clutter/cally/cally-actor.c
Expand Up @@ -947,7 +947,7 @@ cally_actor_action_set_description (AtkAction *action,
if (info == NULL)
return FALSE;

g_free (info->description);
free (info->description);
info->description = g_strdup (desc);

return TRUE;
Expand Down Expand Up @@ -1236,9 +1236,9 @@ _cally_actor_destroy_action_info (gpointer action_info,

g_assert (info != NULL);

g_free (info->name);
g_free (info->description);
g_free (info->keybinding);
free (info->name);
free (info->description);
free (info->keybinding);

if (info->notify)
info->notify (info->user_data);
Expand Down
2 changes: 1 addition & 1 deletion clutter/clutter/cally/cally-factory.h
Expand Up @@ -93,7 +93,7 @@ type_as_function ## _factory_get_type (void) \
name = g_strconcat (g_type_name (type), "Factory", NULL); \
t = g_type_register_static ( \
ATK_TYPE_OBJECT_FACTORY, name, &tinfo, 0); \
g_free (name); \
free (name); \
} \
\
return t; \
Expand Down
8 changes: 4 additions & 4 deletions clutter/clutter/cally/cally-text.c
Expand Up @@ -750,7 +750,7 @@ pango_layout_get_line_after (PangoLayout *layout,
* atk_text_get_text_after_offset().
*
* Returns: a newly allocated string containing a slice of text
* from layout. Free with g_free().
* from layout. Free with free().
*/
static gchar *
_gtk_pango_get_text_at (PangoLayout *layout,
Expand Down Expand Up @@ -849,7 +849,7 @@ _gtk_pango_get_text_at (PangoLayout *layout,
* atk_text_get_text_before_offset().
*
* Returns: a newly allocated string containing a slice of text
* from layout. Free with g_free().
* from layout. Free with free().
*/
static gchar *
_gtk_pango_get_text_before (PangoLayout *layout,
Expand Down Expand Up @@ -950,7 +950,7 @@ _gtk_pango_get_text_before (PangoLayout *layout,
* atk_text_get_text_after_offset().
*
* Returns: a newly allocated string containing a slice of text
* from layout. Free with g_free().
* from layout. Free with free().
*/
static gchar *
_gtk_pango_get_text_after (PangoLayout *layout,
Expand Down Expand Up @@ -1860,7 +1860,7 @@ _cally_misc_add_attribute (AtkAttributeSet *attrib_set,
gchar *value)
{
AtkAttributeSet *return_set;
AtkAttribute *at = g_malloc (sizeof (AtkAttribute));
AtkAttribute *at = malloc (sizeof (AtkAttribute));
at->name = g_strdup (atk_text_attribute_get_name (attr));
at->value = value;
return_set = g_slist_prepend(attrib_set, at);
Expand Down
6 changes: 3 additions & 3 deletions clutter/clutter/cally/cally-util.c
Expand Up @@ -156,7 +156,7 @@ cally_util_add_key_event_listener (AtkKeySnoopFunc listener,

if (!key_listener_list)
{
key_listener_list = g_hash_table_new_full (NULL, NULL, NULL, g_free);
key_listener_list = g_hash_table_new_full (NULL, NULL, NULL, free);

cally_util_simulate_snooper_install ();
}
Expand Down Expand Up @@ -414,8 +414,8 @@ cally_key_snooper (ClutterActor *actor,
consumed = g_hash_table_foreach_steal (new_hash, notify_hf, key_event);
g_hash_table_destroy (new_hash);

g_free (key_event->string);
g_free (key_event);
free (key_event->string);
free (key_event);
}

return (consumed ? 1 : 0);
Expand Down
4 changes: 2 additions & 2 deletions clutter/clutter/clutter-actor-meta.c
Expand Up @@ -167,7 +167,7 @@ clutter_actor_meta_finalize (GObject *gobject)
if (priv->destroy_id != 0 && priv->actor != NULL)
g_signal_handler_disconnect (priv->actor, priv->destroy_id);

g_free (priv->name);
free (priv->name);

G_OBJECT_CLASS (clutter_actor_meta_parent_class)->finalize (gobject);
}
Expand Down Expand Up @@ -257,7 +257,7 @@ clutter_actor_meta_set_name (ClutterActorMeta *meta,
if (g_strcmp0 (meta->priv->name, name) == 0)
return;

g_free (meta->priv->name);
free (meta->priv->name);
meta->priv->name = g_strdup (name);

g_object_notify_by_pspec (G_OBJECT (meta), obj_props[PROP_NAME]);
Expand Down
42 changes: 21 additions & 21 deletions clutter/clutter/clutter-actor.c
Expand Up @@ -24,7 +24,7 @@

/**
* SECTION:clutter-actor
* @short_description: The basic element of the scene graph
* @short_description: The basic element of the scene graph
*
* The ClutterActor class is the basic element of the scene graph in Clutter,
* and it encapsulates the position, size, and transformations of a node in
Expand Down Expand Up @@ -3206,7 +3206,7 @@ _clutter_actor_paint_cull_result (ClutterActor *self,
0,
&color,
0);
g_free (label);
free (label);
g_object_unref (layout);
}
}
Expand Down Expand Up @@ -4525,7 +4525,7 @@ clutter_actor_set_rotation_center_internal (ClutterActor *self,
ClutterRotateAxis axis,
const ClutterVertex *center)
{
ClutterVertex v = CLUTTER_VERTEX_INIT_ZERO;
ClutterVertex v = CLUTTER_VERTEX_INIT_ZERO;
GObject *obj = G_OBJECT (self);
ClutterTransformInfo *info;

Expand Down Expand Up @@ -5790,10 +5790,10 @@ clutter_actor_finalize (GObject *object)
_clutter_actor_get_debug_name ((ClutterActor *) object),
g_type_name (G_OBJECT_TYPE (object)));

g_free (priv->name);
free (priv->name);

#ifdef CLUTTER_ENABLE_DEBUG
g_free (priv->debug_name);
free (priv->debug_name);
#endif

G_OBJECT_CLASS (clutter_actor_parent_class)->finalize (object);
Expand Down Expand Up @@ -11711,7 +11711,7 @@ clutter_actor_set_name (ClutterActor *self,
{
g_return_if_fail (CLUTTER_IS_ACTOR (self));

g_free (self->priv->name);
free (self->priv->name);
self->priv->name = g_strdup (name);

g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_NAME]);
Expand Down Expand Up @@ -13930,7 +13930,7 @@ clutter_actor_get_anchor_point_gravity (ClutterActor *self)
*
* Since: 0.6
*
* Deprecated: 1.12: Use #ClutterActor:pivot-point and
* Deprecated: 1.12: Use #ClutterActor:pivot-point and
* clutter_actor_set_translation() instead.
*/
void
Expand Down Expand Up @@ -13978,7 +13978,7 @@ clutter_actor_move_anchor_point (ClutterActor *self,
*
* Since: 0.6
*
* Deprecated: 1.12: Use #ClutterActor:pivot-point and
* Deprecated: 1.12: Use #ClutterActor:pivot-point and
* clutter_actor_set_translation() instead.
*/
void
Expand Down Expand Up @@ -14030,7 +14030,7 @@ clutter_actor_move_anchor_point_from_gravity (ClutterActor *self,
*
* Since: 0.6
*
* Deprecated: 1.12: Use #ClutterActor:pivot-point and
* Deprecated: 1.12: Use #ClutterActor:pivot-point and
* clutter_actor_set_translation() instead. E.g. For %CLUTTER_GRAVITY_CENTER set
* pivot_point to (0.5,0.5) and the translation to (width/2,height/2).
*/
Expand Down Expand Up @@ -14555,7 +14555,7 @@ clutter_actor_set_custom_property (ClutterScriptable *scriptable,
name,
tmp);

g_free (tmp);
free (tmp);
}
#endif /* CLUTTER_ENABLE_DEBUG */

Expand Down Expand Up @@ -14725,7 +14725,7 @@ clutter_actor_find_property (ClutterAnimatable *animatable,
pspec = g_object_class_find_property (klass, property_name);
}

g_free (p_name);
free (p_name);

return pspec;
}
Expand All @@ -14747,7 +14747,7 @@ clutter_actor_get_initial_state (ClutterAnimatable *animatable,
else
g_object_get_property (G_OBJECT (animatable), property_name, initial);

g_free (p_name);
free (p_name);
}

/*
Expand Down Expand Up @@ -14921,7 +14921,7 @@ clutter_actor_set_final_state (ClutterAnimatable *animatable,
}
}

g_free (p_name);
free (p_name);
}

static void
Expand Down Expand Up @@ -15587,7 +15587,7 @@ update_pango_context (ClutterBackend *backend,
pango_cairo_context_set_resolution (context, resolution);

pango_font_description_free (font_desc);
g_free (font_name);
free (font_name);
}

/**
Expand Down Expand Up @@ -18860,7 +18860,7 @@ transition_closure_free (gpointer data)
/* remove the reference added in add_transition_internal() */
g_object_unref (clos->transition);

g_free (clos->name);
free (clos->name);

g_slice_free (TransitionClosure, clos);
}
Expand Down Expand Up @@ -18916,7 +18916,7 @@ on_transition_stopped (ClutterTransition *transition,
t_name,
is_finished);

g_free (t_name);
free (t_name);

/* if it's the last transition then we clean up */
if (g_hash_table_size (info->transitions) == 0)
Expand Down Expand Up @@ -19081,7 +19081,7 @@ _clutter_actor_create_transition (ClutterActor *actor,
if (error != NULL)
{
g_critical ("%s: %s", G_STRLOC, error);
g_free (error);
free (error);
goto out;
}

Expand All @@ -19092,7 +19092,7 @@ _clutter_actor_create_transition (ClutterActor *actor,
{
g_critical ("%s: %s", G_STRLOC, error);
g_value_unset (&initial);
g_free (error);
free (error);
goto out;
}

Expand Down Expand Up @@ -19151,8 +19151,8 @@ _clutter_actor_create_transition (ClutterActor *actor,
info->cur_state->easing_delay,
initial_v, final_v);

g_free (initial_v);
g_free (final_v);
free (initial_v);
free (final_v);
}
#endif /* CLUTTER_ENABLE_DEBUG */

Expand Down Expand Up @@ -19298,7 +19298,7 @@ clutter_actor_remove_transition (ClutterActor *self,
FALSE);
}

g_free (t_name);
free (t_name);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions clutter/clutter/clutter-backend.c
Expand Up @@ -125,7 +125,7 @@ clutter_backend_finalize (GObject *gobject)

g_source_destroy (backend->cogl_source);

g_free (backend->font_name);
free (backend->font_name);
clutter_backend_set_font_options (backend, NULL);
g_clear_object (&backend->input_method);

Expand Down Expand Up @@ -155,7 +155,7 @@ get_units_per_em (ClutterBackend *backend,
font_desc = pango_font_description_from_string (font_name);
free_font_desc = TRUE;

g_free (font_name);
free (font_name);
}
}

Expand Down Expand Up @@ -1170,7 +1170,7 @@ clutter_backend_get_font_name (ClutterBackend *backend)
/* XXX yuck. but we return a const pointer, so we need to
* store it in the backend
*/
g_free (backend->font_name);
free (backend->font_name);
g_object_get (settings, "font-name", &backend->font_name, NULL);

return backend->font_name;
Expand Down
14 changes: 7 additions & 7 deletions clutter/clutter/clutter-container.c
Expand Up @@ -1222,7 +1222,7 @@ clutter_container_child_set (ClutterContainer *container,
GObjectClass *klass;
const gchar *name;
va_list var_args;

g_return_if_fail (CLUTTER_IS_CONTAINER (container));
g_return_if_fail (CLUTTER_IS_ACTOR (actor));

Expand All @@ -1236,7 +1236,7 @@ clutter_container_child_set (ClutterContainer *container,
GValue value = G_VALUE_INIT;
gchar *error = NULL;
GParamSpec *pspec;

pspec = clutter_container_class_find_child_property (klass, name);
if (!pspec)
{
Expand Down Expand Up @@ -1265,7 +1265,7 @@ clutter_container_child_set (ClutterContainer *container,
* on it might crash
*/
g_warning ("%s: %s", G_STRLOC, error);
g_free (error);
free (error);
break;
}

Expand Down Expand Up @@ -1357,7 +1357,7 @@ clutter_container_child_get_property (ClutterContainer *container,
*
* In general, a copy is made of the property contents and the caller is
* responsible for freeing the memory in the appropriate manner for the type, for
* instance by calling g_free() or g_object_unref().
* instance by calling free() or g_object_unref().
*
* Since: 0.8
*/
Expand All @@ -1370,7 +1370,7 @@ clutter_container_child_get (ClutterContainer *container,
GObjectClass *klass;
const gchar *name;
va_list var_args;

g_return_if_fail (CLUTTER_IS_CONTAINER (container));
g_return_if_fail (CLUTTER_IS_ACTOR (actor));

Expand All @@ -1384,7 +1384,7 @@ clutter_container_child_get (ClutterContainer *container,
GValue value = G_VALUE_INIT;
gchar *error = NULL;
GParamSpec *pspec;

pspec = clutter_container_class_find_child_property (klass, name);
if (!pspec)
{
Expand All @@ -1408,7 +1408,7 @@ clutter_container_child_get (ClutterContainer *container,
if (error)
{
g_warning ("%s: %s", G_STRLOC, error);
g_free (error);
free (error);
g_value_unset (&value);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion clutter/clutter/clutter-debug.h
Expand Up @@ -63,7 +63,7 @@ typedef enum {
if (G_UNLIKELY (CLUTTER_HAS_DEBUG (type))) { \
gchar *_fmt = g_strdup_printf (__VA_ARGS__); \
_clutter_debug_message ("[" #type "]:" G_STRLOC ": %s", _fmt); \
g_free (_fmt); \
free (_fmt); \
} } G_STMT_END
#endif

Expand Down

0 comments on commit 317c06f

Please sign in to comment.