E_OUTOFMEMORY, Heap corruption
E_OUTOFMEMORY, Heap corruption
这个代码有什么问题:
HRESULT AllocateAndFillOutParameters(DWORD * a_Attrib_Count, BSTR ** a_AttribName, DWORD** a_AttribId,BSTR** a_AttribDescription, BSTR** a_AttribDataType,
BSTR** a_AttribAdvanceDataType,DWORD** a_attribfieldlength, VECTOROFATTRIBUTESSTRUCT a_vectAttributes )
{
HRESULT hr = S_OK;
VECTOROFATTRIBUTESSTRUCT::iterator itr_vectCategory = a_vectAttributes.begin();
// Memory Allocation
*a_Attrib_Count = a_vectAttributes.size();
*a_AttribName = (BSTR*)CoTaskMemAlloc(*a_Attrib_Count * sizeof(BSTR));
*a_AttribDescription = (BSTR*)CoTaskMemAlloc(*a_Attrib_Count * sizeof(BSTR));
*a_AttribId = (DWORD*)CoTaskMemAlloc(*a_Attrib_Count * sizeof(DWORD));
*a_AttribDataType = (BSTR*)CoTaskMemAlloc(*a_Attrib_Count * sizeof(BSTR));
*a_AttribAdvanceDataType = (BSTR*)CoTaskMemAlloc(*a_Attrib_Count * sizeof(BSTR));
*a_attribfieldlength = (DWORD*)CoTaskMemAlloc(*a_Attrib_Count * sizeof(DWORD));
//
for(int i=0 ;itr_vectCategory != a_vectAttributes.end(); itr_vectCategory++, i++)
{
*((*a_AttribName)+i) = SysAllocString(itr_vectCategory->m_strAttributeName.c_str());
*((*a_AttribId)+i) = itr_vectCategory->m_dwAttributeId;
*((*a_AttribDescription)+i) = SysAllocString(itr_vectCategory->m_strAttributeDescription.c_str());
*((*a_AttribDataType)+i) = SysAllocString(itr_vectCategory->m_strAttributeDataType.c_str());
*((*a_AttribAdvanceDataType)+i) = SysAllocString(itr_vectCategory->m_strAttributeAdvanceDataType.c_str());
*((*a_attribfieldlength)+i) = (itr_vectCategory->m_dwAttributeFieldLength);
}
return hr;
}
它给出了堆损坏的运行时异常,我是否以错误的方式分配?谢谢你的帮助。
我不能告诉你错误在哪里,但我建议下载适用于Windows的调试工具,然后阅读有关使用gflags
程序启用页面堆调试的文档,这可能会让你发现堆损坏实际发生的错误。
相关文章:
- 为什么我的 heap.h 文件给我一个LNK2001错误?
- 当为可变性配置时,boost::heap::d_ary_heap 保留的额外 std::list 的目的是什么?
- 了解 Linux 虚拟内存:valgrind 的 massif 输出显示了有和没有 --pages-as-heap 的主要差异
- 逻辑'double free or corruption (fasttop)'错误
- emplace_back和push_back给出错误'double free or corruption (fasttop)'尽管定义了复制和移动构造函数
- 从 MSVC14 切换到 MSVC16 会导致"compiler is out of heap space (C1060)"错误
- 庞大的初始化列表,如何修复"fatal error C1060: compiler is out of heap space"
- C++ 调用析构函数后动态模板队列"double free or corruption (out)"
- 为什么这段代码会导致"heap corruption detected"?
- Windows heap corruption C++C
- Heap corruption after new char[strlen
- Corruption Of Heap
- 如何调试我的"heap corruption"?(C++)
- E_OUTOFMEMORY, Heap corruption
- OpenCV findContours - 2.4.5 Heap Corruption
- 释放内存时获得"Heap Corruption Detected: after Normal block"
- Heap corruption C++
- Convex hull & Heap corruption with openCV
- 为什么在这里返回一个 malloc'd 指针会导致免费"HEAP CORRUPTION"?
- C++ Heap Corruption