void CMapStringToString::RemoveAll() { ASSERT_VALID(this); if (m_pHashTable != NULL) { // destroy elements for (UINT nHash = 0; nHash < m_nHashTableSize; nHash++) { CAssoc* pAssoc; for (pAssoc = m_pHashTable[nHash]; pAssoc != NULL; pAssoc = pAssoc->pNext) { DestructElement(&pAssoc->key); // free up string data DestructElement(&pAssoc->value); } } // free hash table delete [] m_pHashTable; m_pHashTable = NULL; } m_nCount = 0; m_pFreeList = NULL; m_pBlocks->FreeDataChain(); m_pBlocks = NULL; }
void CMapStringToString::FreeAssoc(CMapStringToString::CAssoc* pAssoc) { DestructElement(&pAssoc->key); // free up string data DestructElement(&pAssoc->value); pAssoc->pNext = m_pFreeList; m_pFreeList = pAssoc; m_nCount--; ASSERT(m_nCount >= 0); // make sure we don't underflow // if no more elements, cleanup completely if (m_nCount == 0) RemoveAll(); }
static void DestructElements(CBotString* pOldData, int nCount) { while (nCount--) { DestructElement(pOldData); pOldData++; } }
static void _DestructElements(CString* pOldData, INT_PTR nCount) { ASSERT(nCount >= 0); while (nCount--) { DestructElement(pOldData); pOldData++; } }
void CStringList::FreeNode(CStringList::CNode* pNode) { DestructElement(&pNode->data); pNode->pNext = m_pNodeFree; m_pNodeFree = pNode; m_nCount--; ASSERT(m_nCount >= 0); // make sure we don't underflow }
void CStringList::RemoveAll() { ASSERT_VALID(this); // destroy elements CNode* pNode; for (pNode = m_pNodeHead; pNode != NULL; pNode = pNode->pNext) DestructElement(&pNode->data); m_nCount = 0; m_pNodeHead = m_pNodeTail = m_pNodeFree = NULL; m_pBlocks->FreeDataChain(); m_pBlocks = NULL; }