Original Post
Hi, I am trying to load the .obj file format. I get memory errors here. physics.exe!_CrtIsValidHeapPointer(const void * pUserData=0x00e52d08) Line 1807 C physics.exe!_msize_dbg(void * pUserData=0x00e52d08, int nBlockUse=2) Line 1291 + 0x9 C physics.exe!_onexit(int (void)* func=0x0045ea90) Line 119 + 0xd C physics.exe!atexit(void (void)* func=0x0045ea90) Line 158 + 0x9 C physics.exe!std::_Nomemory() Line 8 + 0x32 C++ physics.exe!operator new(unsigned int size=36) Line 15 C++ physics.exe!operator new[](unsigned int count=36) Line 7 + 0x9 C++ As you can see CrtIsValidHeapPointer returns false where it should return true... So What exactly is the problem. I mean my system has enough memory but it could run out of heap because in the same function i create 6000 CVector3 s. Thanks
case 'f':
int t,format;
long currentStart;
currentStart = ftell(f);
readln(f,buffer);
// Format can be one of three
// "f vertexIndex1 vertexIndex2 vertexIndex3 .."
// "f vertexIndex1/coordIndex1 vertexIndex2/coordIndex2 vertexIndex3/coordIndex3 .."
// "f vertexIndex1/coordIndex1/normalIndex1 vertexIndex2/coordIndex2/normalIndex2 vertexIndex3/coordIndex3/normalIndex3 .."
/*if (sscanf(buffer," %d/%d/%d",&t,&t,&t) > 0) format = 2;
else if (sscanf(buffer," %d/%d %d/%d",&t,&t,&t,&t) > 0) format = 1;
else if (sscanf(buffer," %d %d",&t,&t) > 0) format = 0;*/
format = 1;
// we must count how many Vertices there are on this face
switch(format)
{
case 0:
t = strcount(buffer,' ');
assert(1);
break;
case 1:
t = strcount(buffer,'/');
break;
case 2:
t = strcount(buffer,'/')/2;
break;
}
face[faceInd].vert = new CVector3[t]; $$$ ERROR HERE
face[faceInd].uv = new CVector3[t];
face[faceInd].sides = t;
fseek(f,currentStart,SEEK_SET);
int vi,ti,ni;
if (format == 1)
{
// Parse
for (int l=0;l < t;l++)
{
fscanf(f," %d/%d",&vi,&ti);
face[faceInd].vert[l] = tmpVert[vi];
face[faceInd].uv[l] = tmpUV[vi];
}
}
faceInd++;
break;