Jump to content
  • Advertisement


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


Using macros to redefine new[] and delete[]

This topic is 6253 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

Hi. I red an article on flipcode that talked about dealing with memory leaks. I''m sure you can find it if you dig a little. In the article the author basically overloaded the new and delete operators and then used a macro that translated the normal new to the overloaded one. Something like this:
#define DEBUG_NEW new(__LINE__, __FILE__)
#ifdef _DEBUG
#define new DEBUG_NEW
He also said that the same can be done for new[] and decided not to post the code because it''s pretty much the same. However, I can''t get it to work with new[] because macro definitions don''t deal with brackets well. Another words #define new[] causes an error. I tried e-mailing the author but didn''t get a responce. Does anyone have any ideas? Thanks.

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!