This code snippet always throws exceptions which has something to do with the heap. When the breakpoint is hit, pFrame is a null pointer. I want the pFrame to be scoped because I want the pFrame to manage itself when it goes out of scope of CreateFrame, I am not sure because the ownership probably has to be transferred to ppNewFrame so that a shared_ptr may be needed.
Actually, I have tested both of the scenarios, using shared and scoped, both didn't work
Any suggestions?
Thanks Jack
HRESULT CAllocateHierarchy::CreateFrame( LPCSTR Name, LPD3DXFRAME* ppNewFrame )
{
HRESULT hr = S_OK;
*ppNewFrame = NULL;
boost::scoped_ptr pFrame(new D3DXFRAME_DERIVED);
//Copy name
if (Name != NULL)
{
hr = AllocateName(Name, &pFrame->Name);
}
//Set the transformation matrices
D3DXMatrixIdentity(&pFrame->TransformationMatrix);
D3DXMatrixIdentity(&pFrame->CombinedTransformationMatrix);
pFrame->pMeshContainer = NULL;
pFrame->pFrameSibling = NULL;
pFrame->pFrameFirstChild = NULL;
//Return the new bone...
*ppNewFrame = (D3DXFRAME*)pFrame.get();
return hr;
}