[virt-tools-list] [PATCH 17/47] Remove 'db' property from entity object to avoid circular reference
Daniel P. Berrange
berrange at redhat.com
Wed Aug 25 19:37:12 UTC 2010
The OsinfoDb object holds a reference to every OsinfoEntity.
If the OsinfoEntity also holds a back-reference to OsinfoDb
then no memory will ever be freed. The back-reference is
not used in the code, so just remove it
* osinfo/osinfo_common.h, osinfo/osinfo_dataread.c,
osinfo/osinfo_entity.c: Remove back-reference to the
OsinfoDb object from OsinfoEntity
---
osinfo/osinfo_common.h | 2 --
osinfo/osinfo_dataread.c | 6 +++---
osinfo/osinfo_entity.c | 14 --------------
3 files changed, 3 insertions(+), 19 deletions(-)
diff --git a/osinfo/osinfo_common.h b/osinfo/osinfo_common.h
index 7be6fd9..b7ff223 100644
--- a/osinfo/osinfo_common.h
+++ b/osinfo/osinfo_common.h
@@ -184,8 +184,6 @@ struct _OsinfoEntityPrivate
// Key: gchar*
// Value: Array of gchar* values for key (multiple values allowed)
GTree *params;
-
- OsinfoDb *db; // Backpointer to db object
};
/** ****************************************************************************
diff --git a/osinfo/osinfo_dataread.c b/osinfo/osinfo_dataread.c
index 4c8c665..8e4183c 100644
--- a/osinfo/osinfo_dataread.c
+++ b/osinfo/osinfo_dataread.c
@@ -433,7 +433,7 @@ static int __osinfoProcessOs(OsinfoDb *db,
if (!id)
return -EINVAL;
- os = g_object_new(OSINFO_TYPE_OS, "id", id, "db", db, NULL);
+ os = g_object_new(OSINFO_TYPE_OS, "id", id, NULL);
free(id);
if (empty)
@@ -552,7 +552,7 @@ static int __osinfoProcessHypervisor(OsinfoDb *db,
return -EINVAL;
- hv = g_object_new(OSINFO_TYPE_HYPERVISOR, "id", id, "db", db, NULL);
+ hv = g_object_new(OSINFO_TYPE_HYPERVISOR, "id", id, NULL);
free(id);
if (empty)
@@ -659,7 +659,7 @@ static int __osinfoProcessDevice(OsinfoDb *db,
if (!id)
return -EINVAL;
- dev = g_object_new(OSINFO_TYPE_DEVICE, "id", id, "db", db, NULL);
+ dev = g_object_new(OSINFO_TYPE_DEVICE, "id", id, NULL);
free(id);
if (empty)
diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c
index 0fd8c59..dce265a 100644
--- a/osinfo/osinfo_entity.c
+++ b/osinfo/osinfo_entity.c
@@ -10,7 +10,6 @@ enum OSI_ENTITY_PROPERTIES {
OSI_ENTITY_PROP_0,
OSI_ENTITY_ID,
- OSI_DB_PTR
};
static void
@@ -27,9 +26,6 @@ osinfo_entity_set_property (GObject *object,
g_free(self->priv->id);
self->priv->id = g_value_dup_string (value);
break;
- case OSI_DB_PTR:
- self->priv->db = g_value_get_pointer (value);
- break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -50,9 +46,6 @@ osinfo_entity_get_property (GObject *object,
case OSI_ENTITY_ID:
g_value_set_string (value, self->priv->id);
break;
- case OSI_DB_PTR:
- g_value_set_pointer(value, self->priv->db);
- break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -90,13 +83,6 @@ osinfo_entity_class_init (OsinfoEntityClass *klass)
g_object_class_install_property (g_klass,
OSI_ENTITY_ID,
pspec);
- pspec = g_param_spec_pointer ("db",
- "Db pointer",
- "Contains backpointer to libosinfo db object.",
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
- g_object_class_install_property (g_klass,
- OSI_DB_PTR,
- pspec);
g_klass->finalize = osinfo_entity_finalize;
g_type_class_add_private (klass, sizeof (OsinfoEntityPrivate));
--
1.7.2.1
More information about the virt-tools-list
mailing list