On Tue, Nov 13, 2007 at 06:58:41PM +0000, Stefan Schulze Frielinghaus wrote:
> Hi,
> 
> I'm pretty new to libxml2 (2.6.29) and have therefor a question about
> memory handling. When I add a new child to a tree e.g.
> xmlNewChild(root_node, NULL, BAD_CAST "test", BAD_CAST testcontent);
> Does the function xmlNewChild copy the content "testcontent" to a new
> buffer? So that a free(testcontent) is safe.

  xmlNodePtr
  xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
              const xmlChar *name, const xmlChar *content);

the values of name and content are not used as is, they are copied
internally. If you dynamically allocated content then its your responsability
to free it.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
[EMAIL PROTECTED]  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to