tinyxml是否存在内存泄露

代码如下:

        TiXmlDeclaration * xmlDec = new TiXmlDeclaration("1.0", "UTF-8", "yes");

        TiXmlDocument * xmlDocs = new TiXmlDocument();

        xmlDocs->LinkEndChild(xmlDec);

        TiXmlElement * element = new TiXmlElement("disk");

        xmlDocs->LinkEndChild(element);

        xmlDocs->SaveFile("myfile.xml");

        delete xmlDocs;

动态生成的xmlDec和elemnet没有释放,是否导致内存泄露???

但是释放内粗,导致运行时候程序出现段错误,看来需要查看源代码!!

        TiXmlDeclaration * xmlDec = new TiXmlDeclaration("1.0", "UTF-8", "yes");

        TiXmlDocument * xmlDocs = new TiXmlDocument();

        xmlDocs->LinkEndChild(xmlDec);

        TiXmlElement * element = new TiXmlElement("disk");

        xmlDocs->LinkEndChild(element);

        xmlDocs->SaveFile("myfile.xml");

        delete xmlDocs;

        delete xmlDec;

        delete element;


你可能感兴趣的:(element,源代码,程序,动态)