On Fri, Oct 07, 2011 at 11:40:58AM +0200, Christophe Fergeau wrote: > GVirConfigObject also contains an xmlNodePtr which is more useful > since it indicates the position of the current config object in > the source XML file. Since xmlNode has a 'doc' member, having > both an xmlNodePtr and an xmlDocPtr in GVirConfigObject is > redundant. > --- > libvirt-gconfig/libvirt-gconfig-object.c | 50 +++++++++++++---------------- > libvirt-gconfig/libvirt-gconfig-object.h | 1 - > libvirt-gconfig/libvirt-gconfig.sym | 1 - > 3 files changed, 22 insertions(+), 30 deletions(-) > > diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c > index 66102ec..b7829c9 100644 > --- a/libvirt-gconfig/libvirt-gconfig-object.c > +++ b/libvirt-gconfig/libvirt-gconfig-object.c > @@ -43,10 +43,6 @@ struct _GVirConfigObjectPrivate > gchar *doc; > gchar *schema; > > - /* FIXME: docHandle is node->doc, can probably be removed to avoid the > - * 2 getting out of sync > - */ > - xmlDocPtr docHandle; > xmlNodePtr node; > }; > > @@ -117,15 +113,17 @@ static void gvir_config_object_set_property(GObject *object, > priv->schema = g_value_dup_string(value); > break; > > - case PROP_NODE: > - priv->node = g_value_get_pointer(value); > - if ((priv->docHandle != NULL) && (priv->docHandle != priv->node->doc)) > - xmlFreeDoc(priv->docHandle); > - if (priv->node) > - priv->docHandle = priv->node->doc; > - else > - priv->docHandle = NULL; > + case PROP_NODE: { > + xmlNodePtr node; > + node = g_value_get_pointer(value); > + if ((priv->node != NULL) > + && (priv->node->doc != NULL) > + && (priv->node->doc != node->doc)) { > + xmlFreeDoc(priv->node->doc); > + } > + priv->node = node; > break; > + } > > default: > G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); > @@ -143,8 +141,12 @@ static void gvir_config_object_finalize(GObject *object) > g_free(priv->doc); > g_free(priv->schema); > > - if (priv->docHandle) > - xmlFreeDoc(priv->docHandle); > + /* FIXME: all objects describing a given XML document will share the > + * same document so we can't destroy it here like this, we need some > + * refcounting to know when to destroy it. > + */ > + if (priv->node) > + xmlFreeDoc(priv->node->doc); This could be reason for creating a trivial GObject to wrap the xmlDocPtr instance, gaining ref counting. ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list