Hi, during the debugging of one of our apps, we found an issue with CCSet that has a chance of causing memory leaks depending on your use of it.
Basically, the problems lie in addObject, removeObject and removeAllObjects functions.
void CCSet::addObject(CCObject *pObject)
{
CC_SAFE_RETAIN(pObject);
m_pSet->insert(pObject);
}
If you attempt to add an object that already exists in the CCSet, the retain count increments but the m_pSet~~>insert function does nothing as std::set only contains unique elements.
<pre>
void CCSet::removeObject
{
m_pSet~~>erase(pObject);
CC_SAFE_RELEASE(pObject);
}
<pre>
void CCSet::removeAllObjects
{
CCSetIterator it;
for ; it != m_pSet~~>end(); ++it)
{
if (! (*it))
{
break;
}
(*it)->release();
}
}