0
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;
}
그것은 힙 손상의 런타임 예외를 제공, 내가 잘못된 방법으로 할당입니까? 도움 주셔서 감사합니다.
이 생산 코드는 무엇입니까? –
루프에서 실제로'(* a_AttribName) + 1'이되어야합니까? '1' 대신'i'를 써야합니까? –
예, 여기에 실수를 입력합니다. – Ehsank