On Tue, 2007-11-13 at 19:18 -0500, Daniel Veillard wrote:
> 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.

That's the behavior I expected and like ;-)
Thanks for clarification.

Regards,
Stefan

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to