I'm doing the following with TinyXml:
TiXmlDocument doc;
TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );
TiXmlElement* main = new TiXmlElement("main");
TiXmlElement* header = new TiXmlElement("header");
header->SetAttribute("attribute","somevalue");
main->LinkEndChild(header);
// ... Add many more TiXmlElment* to other elements all within "main" element
doc.LinkEndChild(decl);
doc.LinkEndChild(main);
// ... do stuff with doc
// Now I am done with my doc. What memory management happens here?
At the end of my program's execution, will all of the TiXmlElement*
be cleaned up when the doc
goes out of scope? Do I need to walk the doc tree and free up all of the memory myself?
The documentation for LinkEndChild
says this:
NOTE: the node to be added is passed by pointer, and will be henceforth owned (and deleted) by tinyXml. This method is efficient and avoids an extra copy, but should be used with care as it uses a different memory model than the other insert functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With