gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Resetting allocated memory

#27655 - ravenq - Mon Oct 18, 2004 1:13 pm

Quick question for the board. Is it possible to reset the allocation pointer for the new operator in c++? I'm playing around with a setup where I load all my level data after a certain point in my code, and at the end of a level, want to quickly delete everything I've assigned by simply moving the pointer used in allocation (well, I'm assuming it's a pointer) back to the position it was in before starting the level, since all the data then effectively becomes useless.

Any simple way to do this? I'm aware this is probably a shortcut to properly managing memory, but it's a much quicker solution I think at least. It will effectively bring the code back to the state it was in before the level was started, since the score, lives, etc, are defined before the level data is allocated.
_________________
The Game is Nothing.
The Playing of it Everything

#27660 - poslundc - Mon Oct 18, 2004 2:08 pm

You can override the new and delete operators. But personally I would just go for static allocation, since it sounds like that's the affect you're trying to simulate anyway.

Dan.