Jump to content
  • Advertisement

Archived

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

squicklid

'delete' Assertion Failures

This topic is 5203 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I get an Assertion Failure when I try to delete a previously allocated with ''new'' array of structs. It isn''t being deleted twice or anything. What could cause this?

Share this post


Link to post
Share on other sites
Advertisement

void Menu::destroy()
{
if (!element) return;

delete element;
element = NULL;

numelements = 0;
}


[edited by - squicklid on April 22, 2004 11:10:31 PM]

Share this post


Link to post
Share on other sites
WHAT does the assert say? Exactly?
And, when you post deletion code, you also need to post allocation code.

Dollars to donuts you''re overwriting right before or right after the element. Thus, right after you allocate the element, you should set two data breakpoints in the debugger, one for the address right before element, and one for the address right after element; if you overwrite structures in the heap, these data breakpoints will show you where it happens.

Share this post


Link to post
Share on other sites
quote:
Original post by squicklid
Actually, putting the [] in after delete worked. But I don''t quite understand that.


There are two different types of new and delete operators. One set is new/delete and the other is new[]/delete[]. They must be matched. That''s all.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!