Archived

This topic is now archived and is closed to further replies.

rebelcoder

Someone please help.Pointer error I cant track down.

Recommended Posts

int tempDebugCount = (pList.vMeshList[j].totalVertCount); if(!tempDebugCount) continue; if((pList[i].vMeshList[j].totalVertCount) != 1) { tempWorld->objects[i].mesh[j].vertexIndex = new unsigned int[(pList[i].vMeshList[j].totalVertCount)]; GLuint *debugTempPointer = new GLuint[(pList[i].vMeshList[j].totalVertCount)]; }else { tempWorld->objects[i].mesh[j].vertexIndex = new unsigned int; } if(!tempWorld->objects[i].mesh[j].vertexIndex) continue; This is the code that i think is generating an error. I follow the entire thing with the debugger and what seems to be happening is that sometime when new is called (tempWorld->objects[i].mesh[j].vertexIndex = new unsigned int it sets the pointer to zero. Also in the output window is says First-chance exception in ReadyToDie.exe (NTDLL.DLL): 0xC0000005: Access Violation. The address of the pointer is set to 0x00000000 i dont know why this is happeing everything else appears to be valid. Can anyone help me with this problem. I am trying to figure out why it would be set to zero. Could there be something before this that could be causing the error. Im pretty sure its not ive checked all other values and they appear to be fine. Is there some detail i am overseeing and what is NTDLL? ive never seen this before. BTW its a function that generates an octree so its recusive. Could i be running out of memory or something? i doubt that because it fails within the first iteration. I have been trying all night to figure out why this is failing. I have back tracked pretty far but to no avail. Could it be something that has nothing to do with the code? Or could the error be generated to an error that occurs way before this part executes. Any views or opinions anyone could offer would be very very helpful i need to have this done by friday and at this rate i dont think ill be able to complete. Other then rewriting everything i cant think of any other reasons why calling new would make the address of the pointer Zer0. When would this happen?Thank you in advance for you help. enhanced code on contact

Share this post


Link to post
Share on other sites
found the error. In case anyone is intrested in knowing new returns zero when there isnt enough free memory in the free store also known as the heap (ref:msdn). Turns out there was an error with the list i was sending into the function. Im still not sure why new was returning zero though because Im sure there was enough memory to allocate from.Thanks.

Share this post


Link to post
Share on other sites
quote:
Original post by rebelcoder
In case anyone is intrested in knowing new returns zero when there isnt enough free memory in the free store also known as the heap (ref:msdn).


Unfortunately, that''s not standard behaviour : new is supposed to throw an exception (std::bad_alloc) when memory allocation fails, unless you specify you want the non-throwing version... (ref:C++ standard).

Were you using VC6 ? I''m not sure if it''s fixed in VC7...


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share this post


Link to post
Share on other sites
wise man say... use source and code tags...
even wiser man say... dont use ''i'' as variable when looping
through array on forum message board...
wisest of all man say... crowded elevator smell very different to midget.

-eldee
;another space monkey;
[ Forced Evolution Studios ]


::evolve::

Do NOT let Dr. Mario touch your genitals. He is not a real doctor!

Share this post


Link to post
Share on other sites