Re: [xml] use of xmlXPathFreeNodeSet ?



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

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 
on 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 object).

Daniel

-- 
Daniel Veillard      | Open Source and Standards, Red Hat
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/


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