Jump to content
  • Advertisement

Archived

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

kill

Using macros to redefine new[] and delete[]

This topic is 6158 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
#endif
  
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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!