[glib/wip/gcleanup] gobject: Don't leak pspecs for ininstantiated interfaces
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gcleanup] gobject: Don't leak pspecs for ininstantiated interfaces
- Date: Fri, 8 Nov 2013 08:36:29 +0000 (UTC)
commit 31d16e80c8f44382e1fceaf69f77763326320ab0
Author: Stef Walter <stefw gnome org>
Date: Fri Nov 8 08:45:41 2013 +0100
gobject: Don't leak pspecs for ininstantiated interfaces
Remove the awkward ownerhsip of pspec by the object. pspecs are
now only owned by the pool, which makes things more predictable.
gobject/gobject.c | 4 ++--
gobject/gparam.c | 9 ++++-----
2 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 828a7ef..b3cd8b1 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -437,9 +437,8 @@ _g_object_type_free_pspecs (GType type)
{
GParamSpec *pspec = node->data;
- g_param_spec_pool_remove (pspec_pool, pspec);
PARAM_SPEC_SET_PARAM_ID (pspec, 0);
- g_param_spec_unref (pspec);
+ g_param_spec_pool_remove (pspec_pool, pspec);
}
g_list_free (list);
}
@@ -534,6 +533,7 @@ install_property_internal (GType g_type,
g_param_spec_ref_sink (pspec);
PARAM_SPEC_SET_PARAM_ID (pspec, property_id);
g_param_spec_pool_insert (pspec_pool, pspec, g_type);
+ g_param_spec_unref (pspec);
}
/**
diff --git a/gobject/gparam.c b/gobject/gparam.c
index bccbc8d..fd7c7ec 100644
--- a/gobject/gparam.c
+++ b/gobject/gparam.c
@@ -917,7 +917,8 @@ g_param_spec_pool_new (gboolean type_prefixing)
memcpy (&pool->mutex, &init_mutex, sizeof (init_mutex));
pool->type_prefixing = type_prefixing != FALSE;
- pool->hash_table = g_hash_table_new (param_spec_pool_hash, param_spec_pool_equals);
+ pool->hash_table = g_hash_table_new_full (param_spec_pool_hash, param_spec_pool_equals,
+ NULL, (GDestroyNotify)g_param_spec_unref);
return pool;
}
@@ -957,7 +958,7 @@ g_param_spec_pool_insert (GParamSpecPool *pool,
g_mutex_lock (&pool->mutex);
pspec->owner_type = owner_type;
g_param_spec_ref (pspec);
- g_hash_table_insert (pool->hash_table, pspec, pspec);
+ g_hash_table_add (pool->hash_table, pspec);
g_mutex_unlock (&pool->mutex);
}
else
@@ -983,9 +984,7 @@ g_param_spec_pool_remove (GParamSpecPool *pool,
if (pool && pspec)
{
g_mutex_lock (&pool->mutex);
- if (g_hash_table_remove (pool->hash_table, pspec))
- g_param_spec_unref (pspec);
- else
+ if (!g_hash_table_remove (pool->hash_table, pspec))
g_warning (G_STRLOC ": attempt to remove unknown pspec '%s' from pool", pspec->name);
g_mutex_unlock (&pool->mutex);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]