#### Archived

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.

## 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.

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 10
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632647
• Total Posts
3007640
• ### Who's Online (See full list)

There are no registered users currently online

×