Menu

#11 Delete old child elements in SOAPElement::operator=

v2.0
open
nobody
Simple SOAP (3)
5
2013-02-14
2013-02-14
BGawenda
No

After clearing the old m_internalElements and assigning the new child elements you need to delete the old m_internalElements. Aren't they lost otherwise?

- // clear any old child elements
// get a copy of old internal elements to free them later
+ ElementContainer temp(m_internalElements);
m_internalElements.clear();

//Change on 07/03/2001 by SM
//Correct copy operator
for(int i=0;i<rhs.numElements();i++)
{
SOAPElement* pElement = new SOAPElement( *rhs.m_internalElements[i] );
addElement( pElement );
}

+ // free old internal elements
+ for(size_t i=0; i < temp.size(); ++i)
+ delete temp[i];

Discussion


Log in to post a comment.

MongoDB Logo MongoDB