From d25cb04713c3373e08e34282f291b85c53881aba Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 20 Jul 2012 18:26:57 +0000 Subject: [PATCH] Removed unnecessary manual memory management from InterfaceKinetics Converted m_rxnPhaseIsReactant and m_rxnPhaseIsProduct from vector to vector >. --- include/cantera/kinetics/InterfaceKinetics.h | 4 +-- src/kinetics/InterfaceKinetics.cpp | 37 +++----------------- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/include/cantera/kinetics/InterfaceKinetics.h b/include/cantera/kinetics/InterfaceKinetics.h index 2e9c16462..021028aa5 100644 --- a/include/cantera/kinetics/InterfaceKinetics.h +++ b/include/cantera/kinetics/InterfaceKinetics.h @@ -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 m_rxnPhaseIsReactant; + std::vector > 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 m_rxnPhaseIsProduct; + std::vector > m_rxnPhaseIsProduct; #ifdef KINETICS_WITH_INTERMEDIATE_ZEROED_PHASES //! Vector of ints indicating whether zeroed phase is an intermediate for diff --git a/src/kinetics/InterfaceKinetics.cpp b/src/kinetics/InterfaceKinetics.cpp index 1cb318b8e..5e98c7100 100644 --- a/src/kinetics/InterfaceKinetics.cpp +++ b/src/kinetics/InterfaceKinetics.cpp @@ -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(nPhases(), false)); + m_rxnPhaseIsProduct.push_back(std::vector(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& vr = reactants(i); for (size_t ik = 0; ik < vr.size(); ik++) { size_t k = vr[ik];