Do i have to use the delete statement for the xmlvalue and xmlfield variables??? if yes, where should i do it?? after the SaveFile? or does the SaveFile free all the memory allocated for the elements inside the TiDocument??
Thanks for any help
AR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using TinyXML and i'm concerned about the memory handling.
Reading this is my method if someone could help me finding the best way to do it keep a correct memory usage
TiXmlDocument doc(filename.c_str());
bool loadOkay = doc.LoadFile();
if ( !loadOkay ) {
printf( "Error Opening the Login XML file %s\n", doc.ErrorDesc() );
}
//Creates a XML Handle
TiXmlHandle docHandle( &doc );
... here i check something in my db, and try to add some fields to the XML...
TiXmlElement * xmlElement;
TiXmlElement * xmlfield;
TiXmlText * xmlvalue;
if(result from db is true){
xmlElement = docHandle.FirstChild( "Data" ).ToElement();
xmlfield = new TiXmlElement( "Field" );
xmlvalue = new TiXmlText("Value");
xmlfield->LinkEndChild(xmlvalue);
xmlElement->LinkEndChild(xmlfield);
}
doc.SaveFile(filename.c_str());
Do i have to use the delete statement for the xmlvalue and xmlfield variables??? if yes, where should i do it?? after the SaveFile? or does the SaveFile free all the memory allocated for the elements inside the TiDocument??
Thanks for any help
AR