Eliminate unnecessary manual memory management of XML_Node
This also eliminates memory leaks that would occur if an exception were raised in these methods.
This commit is contained in:
parent
70b51c797c
commit
d7cbb30086
7 changed files with 23 additions and 32 deletions
|
|
@ -98,11 +98,11 @@ FixedChemPotSSTP::FixedChemPotSSTP(const std::string& Ename, doublereal val) :
|
|||
setChemicalPotential(val);
|
||||
|
||||
// Create an XML_Node entry for this species
|
||||
XML_Node* s = new XML_Node("species", 0);
|
||||
s->addAttribute("name", pname);
|
||||
XML_Node s("species", 0);
|
||||
s.addAttribute("name", pname);
|
||||
std::string aaS = Ename + ":1";
|
||||
s->addChild("atomArray", aaS);
|
||||
XML_Node& tt = s->addChild("thermo");
|
||||
s.addChild("atomArray", aaS);
|
||||
XML_Node& tt = s.addChild("thermo");
|
||||
XML_Node& ss = tt.addChild("Simple");
|
||||
ss.addAttribute("Pref", "1 bar");
|
||||
ss.addAttribute("Tmax", "5000.");
|
||||
|
|
@ -112,9 +112,7 @@ FixedChemPotSSTP::FixedChemPotSSTP(const std::string& Ename, doublereal val) :
|
|||
std::string sval = fp2str(val);
|
||||
ss.addChild("h", sval);
|
||||
ss.addChild("s", "0.0");
|
||||
saveSpeciesData(0, s);
|
||||
delete s;
|
||||
s = 0;
|
||||
saveSpeciesData(0, &s);
|
||||
}
|
||||
|
||||
FixedChemPotSSTP::FixedChemPotSSTP(const FixedChemPotSSTP& right)
|
||||
|
|
|
|||
|
|
@ -979,10 +979,9 @@ void HMWSoln::constructPhaseFile(std::string inputFile, std::string id_)
|
|||
* The phase object automatically constructs an XML object.
|
||||
* Use this object to store information.
|
||||
*/
|
||||
XML_Node* fxml = new XML_Node();
|
||||
fxml->build(fin);
|
||||
XML_Node* fxml_phase = findXMLPhase(fxml, id_);
|
||||
|
||||
XML_Node fxml;
|
||||
fxml.build(fin);
|
||||
XML_Node* fxml_phase = findXMLPhase(&fxml, id_);
|
||||
if (!fxml_phase) {
|
||||
throw CanteraError("HMWSoln:constructPhaseFile",
|
||||
"ERROR: Can not find phase named " +
|
||||
|
|
@ -990,7 +989,6 @@ void HMWSoln::constructPhaseFile(std::string inputFile, std::string id_)
|
|||
}
|
||||
setXMLdata(*fxml_phase);
|
||||
constructPhaseXML(*fxml_phase, id_);
|
||||
delete fxml;
|
||||
}
|
||||
|
||||
void HMWSoln::constructPhaseXML(XML_Node& phaseNode, std::string id_)
|
||||
|
|
|
|||
|
|
@ -110,9 +110,9 @@ void PDSS_ConstVol::constructPDSSFile(VPStandardStateTP* tp, size_t spindex,
|
|||
* Use this object to store information.
|
||||
*/
|
||||
|
||||
XML_Node* fxml = new XML_Node();
|
||||
fxml->build(fin);
|
||||
XML_Node* fxml_phase = findXMLPhase(fxml, id);
|
||||
XML_Node fxml;
|
||||
fxml.build(fin);
|
||||
XML_Node* fxml_phase = findXMLPhase(&fxml, id);
|
||||
if (!fxml_phase) {
|
||||
throw CanteraError("PDSS_ConstVol::initThermo",
|
||||
"ERROR: Can not find phase named " +
|
||||
|
|
@ -125,7 +125,6 @@ void PDSS_ConstVol::constructPDSSFile(VPStandardStateTP* tp, size_t spindex,
|
|||
const XML_Node* s = speciesDB->findByAttr("name", tp->speciesName(spindex));
|
||||
|
||||
constructPDSSXML(tp, spindex, *s, *fxml_phase, true);
|
||||
delete fxml;
|
||||
}
|
||||
|
||||
void PDSS_ConstVol::initThermoXML(const XML_Node& phaseNode, const std::string& id)
|
||||
|
|
|
|||
|
|
@ -709,9 +709,9 @@ void PDSS_HKFT::constructPDSSFile(VPStandardStateTP* tp, size_t spindex,
|
|||
* Use this object to store information.
|
||||
*/
|
||||
|
||||
XML_Node* fxml = new XML_Node();
|
||||
fxml->build(fin);
|
||||
XML_Node* fxml_phase = findXMLPhase(fxml, id);
|
||||
XML_Node fxml;
|
||||
fxml.build(fin);
|
||||
XML_Node* fxml_phase = findXMLPhase(&fxml, id);
|
||||
if (!fxml_phase) {
|
||||
throw CanteraError("PDSS_HKFT::initThermo",
|
||||
"ERROR: Can not find phase named " +
|
||||
|
|
@ -724,7 +724,6 @@ void PDSS_HKFT::constructPDSSFile(VPStandardStateTP* tp, size_t spindex,
|
|||
const XML_Node* s = speciesDB->findByAttr("name", tp->speciesName(spindex));
|
||||
|
||||
constructPDSSXML(tp, spindex, *s, *fxml_phase, true);
|
||||
delete fxml;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MODE
|
||||
|
|
|
|||
|
|
@ -91,16 +91,15 @@ void PDSS_IdealGas::constructPDSSFile(VPStandardStateTP* tp, size_t spindex,
|
|||
* Use this object to store information.
|
||||
*/
|
||||
|
||||
XML_Node* fxml = new XML_Node();
|
||||
fxml->build(fin);
|
||||
XML_Node* fxml_phase = findXMLPhase(fxml, id);
|
||||
XML_Node fxml;
|
||||
fxml.build(fin);
|
||||
XML_Node* fxml_phase = findXMLPhase(&fxml, id);
|
||||
if (!fxml_phase) {
|
||||
throw CanteraError("PDSS_IdealGas::constructPDSSFile",
|
||||
"ERROR: Can not find phase named " +
|
||||
id + " in file named " + inputFile);
|
||||
}
|
||||
constructPDSSXML(tp, spindex, *fxml_phase, id);
|
||||
delete fxml;
|
||||
}
|
||||
|
||||
void PDSS_IdealGas::initThermo()
|
||||
|
|
|
|||
|
|
@ -181,9 +181,9 @@ void PDSS_IonsFromNeutral::constructPDSSFile(VPStandardStateTP* tp, size_t spind
|
|||
* Use this object to store information.
|
||||
*/
|
||||
|
||||
XML_Node* fxml = new XML_Node();
|
||||
fxml->build(fin);
|
||||
XML_Node* fxml_phase = findXMLPhase(fxml, id);
|
||||
XML_Node fxml;
|
||||
fxml.build(fin);
|
||||
XML_Node* fxml_phase = findXMLPhase(&fxml, id);
|
||||
if (!fxml_phase) {
|
||||
throw CanteraError("PDSS_IonsFromNeutral::constructPDSSFile",
|
||||
"ERROR: Can not find phase named " +
|
||||
|
|
@ -196,7 +196,6 @@ void PDSS_IonsFromNeutral::constructPDSSFile(VPStandardStateTP* tp, size_t spind
|
|||
const XML_Node* s = speciesDB->findByAttr("name", tp->speciesName(spindex));
|
||||
|
||||
constructPDSSXML(tp, spindex, *s, *fxml_phase, id);
|
||||
delete fxml;
|
||||
}
|
||||
|
||||
void PDSS_IonsFromNeutral::initThermo()
|
||||
|
|
|
|||
|
|
@ -139,9 +139,9 @@ void PDSS_SSVol::constructPDSSFile(VPStandardStateTP* tp, size_t spindex,
|
|||
* Use this object to store information.
|
||||
*/
|
||||
|
||||
XML_Node* fxml = new XML_Node();
|
||||
fxml->build(fin);
|
||||
XML_Node* fxml_phase = findXMLPhase(fxml, id);
|
||||
XML_Node fxml;
|
||||
fxml.build(fin);
|
||||
XML_Node* fxml_phase = findXMLPhase(&fxml, id);
|
||||
if (!fxml_phase) {
|
||||
throw CanteraError("PDSS_SSVol::initThermo",
|
||||
"ERROR: Can not find phase named " +
|
||||
|
|
@ -154,7 +154,6 @@ void PDSS_SSVol::constructPDSSFile(VPStandardStateTP* tp, size_t spindex,
|
|||
const XML_Node* s = speciesDB->findByAttr("name", tp->speciesName(spindex));
|
||||
|
||||
constructPDSSXML(tp, spindex, *s, *fxml_phase, true);
|
||||
delete fxml;
|
||||
}
|
||||
|
||||
void PDSS_SSVol::initThermoXML(const XML_Node& phaseNode, const std::string& id)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue