Hi
I am trying to add an element to a vector with this code:
Code:
//newMaterial is initted here a bit above:
tMaterial newMaterial = {0};
//Here is the push_back function
pModel->numOfMaterials++;
pModel->pMaterials.push_back(newMaterial);
memset(&(pModel->pMaterials[pModel->numOfMaterials - 1]), 0, sizeof(newMaterial));
The first element that I add works fine, but the second makes the program crash with this error (in MSVC 7):
Debug error!
DAMAGE: after normal block (#53) at 0x003DF6C0
I have a similar function that looks like this, and as far as I know it doesn't crash after more than one object:
Code:
tDobj newObject = {0};
pModel->numOfObjects++;
pModel->pObject.push_back(newObject);
memset(&(pModel->pObject[pModel->numOfObjects - 1]), 0, sizeof(newObject));
Anyone know if there's anything wrong here, or do I need to post more code?
Thanks in advance
The Wazaa
Edit:
Here is the declaration of those vectors:
Code:
vector<tDobj> pObject;
vector<tMaterial> pMaterials;