Archived

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

kill

Using macros to redefine new[] and delete[]

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