LPDIRECTDRAWSURFACE7* lpDDFrame;
// Some code... (Creation)
lpDDFrame = new LPDIRECTDRAWSURFACE7[nFrames];
// Deletion
for (int iFrame = 0; iFrame < nFrames; ++iFrame)
{
lpDDFrame[iFrame]->Release();
}
delete [] lpDDFrame; <-- Error on this line
lpDDFrame = NULL;
On the line I indicated up there, the whole application locks up. I hear a beep that seems to indicate an error Message Box, but I see none.
Before you ask, of course I'm checking to see that the pointer is null before deleting it.
Help if you can.
-Edit: I saw the message box finally after running a couple of times, and it's a "Damage After Normal Block" message. I know what that is, but how do I fix it? Thanks.-
Trigon
I like food.
Edited by - TrigonLoki on 5/28/00 8:42:44 PM
Proper Deletion of Dynamic Arrays?
Hello all! How are you doing?
I have a dynamic array that I'm allocating, but having touble deleting. Uh-oh..
I like food.
Damage after normal block usually indicates that at some point you overwrote the end of the array. Double check the bounds on all accesses to the array. ex: your loops run from 0 to nFrames-1.
Do your compiler not give errors ?? or did you cut too much in the post ???. You allocate LPDIRECTDRAWSURFACE7 objects, not pointers to them. So try change the release call to:
lpDDFrame[iFrame].Release();
?!?!?
Edited by - Claus Hansen Ries on May 29, 2000 3:10:10 PM
Edited by - Claus Hansen Ries on May 29, 2000 3:13:39 PM
lpDDFrame[iFrame].Release();
?!?!?
Edited by - Claus Hansen Ries on May 29, 2000 3:10:10 PM
Edited by - Claus Hansen Ries on May 29, 2000 3:13:39 PM
Ries
No, LPDIRECTDRAWSURFACE7 is IDirectDraw7*, hence the LP (long pointer, I think).
Besides, that would have given a compiler error, and he couldn''t have run the program if that were the mistake.
Besides, that would have given a compiler error, and he couldn''t have run the program if that were the mistake.
Well, I decided that I had screwed something up deep iside the code and would never find it. So I scrapped the dynamic system and took a slightly different approach.
It''s not working either, but the memory bugs are gone! Joy... It looks like I''m just gonna start my AniBmp class all over again.
Oh well, no rush. My "designer" just walked, and took all his ideas with him, which means I get to start on something compeletely new by myself! . I''m so excited...
I got almost the same situation to work in a test application, so I''m not quite sure what the problem was, but I''m sure I was writing past like SiCrane said.
Thanks anyway.
Trigon
P.S. SiCrane, you''ve been the most helpful poster in every single question I''ve had so far, if I remember correctly. Questions on programming, at least. Thanks a lot! And thanks to all the very nice and courteous people here!
I like food.
It''s not working either, but the memory bugs are gone! Joy... It looks like I''m just gonna start my AniBmp class all over again.
Oh well, no rush. My "designer" just walked, and took all his ideas with him, which means I get to start on something compeletely new by myself! . I''m so excited...
I got almost the same situation to work in a test application, so I''m not quite sure what the problem was, but I''m sure I was writing past like SiCrane said.
Thanks anyway.
Trigon
P.S. SiCrane, you''ve been the most helpful poster in every single question I''ve had so far, if I remember correctly. Questions on programming, at least. Thanks a lot! And thanks to all the very nice and courteous people here!
I like food.
I like food.
I just had that problem myself and it was a pain to track down.
SiCrane was right when he said that you probably violated the bounds of the array somehow and that can go both low and high.
I used ::AfxCheckMemory peppered around my code to track down the module that was complaining and then narrowed the search down in that module. After I knew what to look for it was easy to find it.
You should see a debug message something like this that will give you a good idea where you initialized the variable for the array (maybe a new) and then just start looking for access elements to that array.
memory check error at $0067495F = $63, should be $FD
DAMAGE: before Non-Object block at $00674960
Non-Object allocated at file test02.cxx(48)
Calen
~freedom
SiCrane was right when he said that you probably violated the bounds of the array somehow and that can go both low and high.
I used ::AfxCheckMemory peppered around my code to track down the module that was complaining and then narrowed the search down in that module. After I knew what to look for it was easy to find it.
You should see a debug message something like this that will give you a good idea where you initialized the variable for the array (maybe a new) and then just start looking for access elements to that array.
memory check error at $0067495F = $63, should be $FD
DAMAGE: before Non-Object block at $00674960
Non-Object allocated at file test02.cxx(48)
Calen
~freedom
Calen~freedom
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement