Re: [xml] libxml2: xmlNewChield and memory control

On Tue, Nov 13, 2007 at 06:58:41PM +0000, Stefan Schulze Frielinghaus wrote:

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.

  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.


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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