Removed unnecessary manual memory management from InterfaceKinetics

Converted m_rxnPhaseIsReactant and m_rxnPhaseIsProduct from
vector<bool*> to vector<vector<bool> >.
This commit is contained in:
Ray Speth 2012-07-20 18:26:57 +00:00
parent d7463cc226
commit d25cb04713
2 changed files with 6 additions and 35 deletions

View file

@ -887,7 +887,7 @@ protected:
* m_rxnPhaseIsReactant[j][p] indicates whether a species in phase p
* participates in reaction j as a reactant.
*/
std::vector<bool*> m_rxnPhaseIsReactant;
std::vector<std::vector<bool> > m_rxnPhaseIsReactant;
//! Vector of vector of booleans indicating whether a phase participates in a
//! reaction as a product
@ -895,7 +895,7 @@ protected:
* m_rxnPhaseIsReactant[j][p] indicates whether a species in phase p
* participates in reaction j as a product.
*/
std::vector<bool*> m_rxnPhaseIsProduct;
std::vector<std::vector<bool> > m_rxnPhaseIsProduct;
#ifdef KINETICS_WITH_INTERMEDIATE_ZEROED_PHASES
//! Vector of ints indicating whether zeroed phase is an intermediate for

View file

@ -108,10 +108,6 @@ InterfaceKinetics::~InterfaceKinetics()
if (m_integrator) {
delete m_integrator;
}
for (size_t i = 0; i < m_ii; i++) {
delete [] m_rxnPhaseIsReactant[i];
delete [] m_rxnPhaseIsProduct[i];
}
}
//====================================================================================================================
// Copy Constructor for the %InterfaceKinetics object.
@ -168,11 +164,6 @@ operator=(const InterfaceKinetics& right)
return *this;
}
for (size_t i = 0; i < m_ii; i++) {
delete [] m_rxnPhaseIsReactant[i];
delete [] m_rxnPhaseIsProduct[i];
}
Kinetics::operator=(right);
m_grt = right.m_grt;
@ -209,19 +200,8 @@ operator=(const InterfaceKinetics& right)
m_phaseExistsCheck = right.m_phaseExistsCheck;
m_phaseExists = right.m_phaseExists;
m_phaseIsStable = right.m_phaseIsStable;
m_rxnPhaseIsReactant.resize(m_ii, 0);
m_rxnPhaseIsProduct.resize(m_ii, 0);
size_t np = nPhases();
for (size_t i = 0; i < m_ii; i++) {
m_rxnPhaseIsReactant[i] = new bool[np];
m_rxnPhaseIsProduct[i] = new bool[np];
for (size_t p = 0; p < np; p++) {
m_rxnPhaseIsReactant[i][p] = right.m_rxnPhaseIsReactant[i][p];
m_rxnPhaseIsProduct[i][p] = right.m_rxnPhaseIsProduct[i][p];
}
}
m_rxnPhaseIsReactant = right.m_rxnPhaseIsReactant;
m_rxnPhaseIsProduct = right.m_rxnPhaseIsProduct;
m_ioFlag = right.m_ioFlag;
return *this;
@ -1070,19 +1050,10 @@ void InterfaceKinetics::addReaction(ReactionData& r)
incrementRxnCount();
m_rxneqn.push_back(r.equation);
m_rxnPhaseIsReactant.resize(m_ii, 0);
m_rxnPhaseIsProduct.resize(m_ii, 0);
m_rxnPhaseIsReactant.push_back(std::vector<bool>(nPhases(), false));
m_rxnPhaseIsProduct.push_back(std::vector<bool>(nPhases(), false));
size_t np = nPhases();
size_t i = m_ii - 1;
m_rxnPhaseIsReactant[i] = new bool[np];
m_rxnPhaseIsProduct[i] = new bool[np];
for (size_t p = 0; p < np; p++) {
m_rxnPhaseIsReactant[i][p] = false;
m_rxnPhaseIsProduct[i][p] = false;
}
const std::vector<size_t>& vr = reactants(i);
for (size_t ik = 0; ik < vr.size(); ik++) {
size_t k = vr[ik];