在使用TinyXml for C++时,我需要清理哪些内存管理?

Ale*_*x B 5 c++ memory-management tinyxml

我正在使用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? 
Run Code Online (Sandbox Code Playgroud)

在我的程序执行结束时,是否会在超出范围TiXmlElement*时清理所有内容doc?我是否需要遍历文档树并释放所有内存?

Rob*_*edy 13

说明这个的文件LinkEndChild:

注意:要添加的节点由指针传递,然后由tinyXml拥有(并删除).此方法很有效并且避免了额外的副本,但是应该小心使用,因为它使用与其他插入函数不同的内存模型.

  • 他不仅不需要,他也不必. (3认同)