if (m_pMapVectorSymbol != NULL)
{
for (TMapVectorSymbol::TMapIterator iter = m_pMapVectorSymbol->m_pMapParameter->begin(); iter != m_pMapVectorSymbol->m_pMapParameter->end(); ++iter)
{
TVectorSymbol *pVectorSymbol = iter->second;
if (pVectorSymbol != NULL)
{
for (TVectorSymbol::iterator iter1 = pVectorSymbol->begin(); iter1 != pVectorSymbol->end(); ++iter1)
{
CMapSingleParameter *pMapSingleParameter = *iter1;
SAFE_DELETE(pMapSingleParameter);
}
SAFE_DELETE(pVectorSymbol);
}
}
SAFE_DELETE(m_pMapVectorSymbol);
}
if (m_pLatelyVectorSymbol != NULL)
{
for (TVectorSymbol::iterator iter = m_pLatelyVectorSymbol->begin(); iter != m_pLatelyVectorSymbol->end(); ++iter)
{
CMapSingleParameter *pMapSingleParameter = *iter;
SAFE_DELETE(pMapSingleParameter);
}
SAFE_DELETE(m_pLatelyVectorSymbol);
}
关于map vector 多层嵌套,最后内存的释放方式
最新推荐文章于 2021-10-09 16:02:02 发布
这篇博客探讨了如何正确释放C++中多层嵌套的map和vector的内存。通过示例代码展示了针对TMapVectorSymbol和TVectorSymbol类型的指针,使用迭代器遍历并逐个删除CMapSingleParameter对象,确保内存得到妥善管理。重点在于理解智能指针与手动内存管理在多层数据结构中的应用。
摘要由CSDN通过智能技术生成