Jump to content
  • Advertisement

Archived

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

gimp

Creating a generic memory manager...

This topic is 6613 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''ve had this idea recently. There''s a whole bunch of stuff that you request from the system that could fail for a whole bunch of reasons, mostly things we care about in a pass\fail kind of way like ''new''ing more ram or creating a thread or mutex. I was thinking about creating a class that would wrap a call to new and do a little smart stuff... Smart stuff that I probably wouldn''t bother with for most of my code if left to my own devices... So I started laying out a class structure that would be able to handle requests to allocate memory. I started off as you might thing, create a string ..''newer'' and then a structure ''newer''... DOH! I bet you guessed that I couldn''t work out how to make my class without a gazillion overload methods that would allow newing of custom types. If this is even possible it must be one of those guru trick''s I see that are rarely documented as all my references don''t have anyhing like what I''m looking at doing. In case I lost you. I want to make a generic memory management class that can accept something like class CManager public: char* New(type something, INT32 Num); ..something that can do the same thing as New but will allow be to do things like: -Check for null return code (Memory allocation failure) -Check to see if passed in pointer is already pointing to an existing block of memory and free(delete) it first so I don''t leak. So the question beg''s, shouldn''t this already exist, or are any of you already doing this? Many many thanks chris

Share this post


Link to post
Share on other sites
Advertisement

  • 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!