Re: [xml] use of xmlXPathFreeNodeSet ?

Thanks !

I now use xmlXPathFreeObject on the result instead of freenodeset on the nodeset member and the leak seems to 
be solved.

Unfortunately I did not have valgrind for my platform so It took some time to figure out where the leak was.

Kind Regards 

-----Oorspronkelijk bericht-----
Van: Daniel Veillard [mailto:veillard redhat com] 
Verzonden: dinsdag 18 juni 2013 15:43
Aan: rbondue ext orange com
CC: Sagaert Johan; xml gnome org
Onderwerp: Re: [xml] use of xmlXPathFreeNodeSet ?

On Tue, Jun 18, 2013 at 09:56:42AM +0200, rbondue ext orange com wrote:

I have run an xpath search on an xmldocument.

Afterwards I call xmlXPathFreeContext and xmlXPathFreeNodeSet to release resources.

Should I call xmlfree on the nodes found in this nodeset before I use xmlXPathFreeNodeSet ?

I really don't think you need to delete the nodes yourself.
I don't know the context of your program, but I never had to use xmlXPathFreeNodeSet(), and instead relied 
xmlXPathFreeObject(). Last time I ran Valgrind on my program, everything seemed ok.

  Confirmed, the nodeset is one part of the full object. Just free the XPath returned object.
  You don't have to free the nodes pointed (but you will have to free the document at the end of processing). 
In general the nodeset
just points to nodes in the document (small exception is namespace nodes but that's taken care by freeing the 


Daniel Veillard      | Open Source and Standards, Red Hat
veillard redhat com  | libxml Gnome XML XSLT toolkit | 
virtualization library

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]