Re: [xml] Can I ask one question about libxml2?



On Fri, Jul 25, 2008 at 09:59:46PM -0500, ChoiJason wrote:

Hello,
 
Let me ask one question I'm struggling with.I found a problem when using xmlFree().
When xmlFree() is called, I think thead look like being hanged.

  Very simple. You can (and should) use xmlFree() for data allocated by
xmlMalloc or xmlRealloc. Basically if libxml2 allocated a structure it
will have an associated function deallocating the structure, use that
it will use it as appropriate. If libxml2 allocated a string, and you
have to free that string then xmlFree() should be used. Note that if
a string pertains to a document, avoid trying to mess up directly with
it and use some of the tree functions to make the modification instead.
And example of xmlFree() use classic in user code is to free the
values returned by xmlGetProp (and similar) used to get the value of an
attribute.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/



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