Advertisement

Memory leak in GameTut#4? (and a correctness about md2 animation)

Started by July 17, 2001 09:09 AM
1 comment, last by HalfLucifer 23 years, 7 months ago
I saw what the Nehe news said that there was a memory leak in GameTut#4 and had been eliminated; I''d like take a look at it, but I cannot find in tut or code where the original memory leak is. Anyone knows that? I found a tiny problem about the MD2 animation in GameTut#4. There would be an abnormal "flip" while the model''s repeating "IDLE"(default animation). In MD2::Animate(), if replacing "if(currentFrame==-1 || currentFrame>endFrame)" with "if(currentFrame==-1 || nextFrame>endFrame)", I think it would get rid of the "flip" problem.
I forget the exact variable names but this is the general idea:

There was an allocation of memory in MD2::Load() I believe

  somePtr = new someType[someSize];  


And it was being deleted in MD2::~MD2()

  delete somePtr;  


However, whenever you allocate an array of memory, you need to delete the whole array.

  delete [] somePtr;  


I hope you get the general idea.

Edited by - Parveen Kaler on July 17, 2001 5:44:52 PM
Advertisement
Ok, thanks... And I should really put a banner on Gamedev.net that says "I HAVE FIXED THE
''delete'' problem!"

NARF!

------------------------------
Trent (ShiningKnight)
E-mail me
OpenGL Game Programming Tutorials

This topic is closed to new replies.

Advertisement