Hi, I am having problems deleting an array in my clear up code of a DirectX application in visual c++. The application runs fine until you exit it or the clean-up code is called for another reason.
The array is defended in the following way:
DWORD g_dwNumModels = 0L; //Used to store the number of used records in the array
typedef struct MODEL_STORAGE_SYSTEM{
D3DMATERIAL8* pMeshMaterials;
LPDIRECT3DTEXTURE8* pMeshTextures;
DWORD dwNumMaterials;
LPD3DXMESH pMesh;
} MSSSTORAGE;
MSSSTORAGE g_mssModels[100];
And I am attempting to delete it using the following method:
if( g_mssModels )
{
DWORD dwModelNumber;
for(dwModelNumber = 0; dwModelNumber < g_dwNumModels; dwModelNumber++)
{
g_mssModels[dwModelNumber].pMesh->Release();
for( DWORD i = 0; i < g_mssModels[dwModelNumber].dwNumMaterials; i++ )
{
if( g_mssModels[dwModelNumber].pMeshTextures )
g_mssModels[dwModelNumber].pMeshTextures->Release();
}
}
delete[] (void *)&g_mssModels;
}
Can any one suggest what I am doing wrong or how you would go about deleting the same array?
David
The array is defended in the following way:
DWORD g_dwNumModels = 0L; //Used to store the number of used records in the array
typedef struct MODEL_STORAGE_SYSTEM{
D3DMATERIAL8* pMeshMaterials;
LPDIRECT3DTEXTURE8* pMeshTextures;
DWORD dwNumMaterials;
LPD3DXMESH pMesh;
} MSSSTORAGE;
MSSSTORAGE g_mssModels[100];
And I am attempting to delete it using the following method:
if( g_mssModels )
{
DWORD dwModelNumber;
for(dwModelNumber = 0; dwModelNumber < g_dwNumModels; dwModelNumber++)
{
g_mssModels[dwModelNumber].pMesh->Release();
for( DWORD i = 0; i < g_mssModels[dwModelNumber].dwNumMaterials; i++ )
{
if( g_mssModels[dwModelNumber].pMeshTextures )
g_mssModels[dwModelNumber].pMeshTextures->Release();
}
}
delete[] (void *)&g_mssModels;
}
Can any one suggest what I am doing wrong or how you would go about deleting the same array?
David