First, thank you for the replies guys.
Originally Posted by
matsp
Show us the code (the macro or whatever).
--
Mats
Well, this is from crtdbg.h
Code:
#ifdef _CRTDBG_MAP_ALLOC
#define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define realloc(p, s) _realloc_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define _recalloc(p, c, s) _recalloc_dbg(p, c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define _expand(p, s) _expand_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define free(p) _free_dbg(p, _NORMAL_BLOCK)
...
#endif /* _CRTDBG_MAP_ALLOC */
I think it is used to wrap the new, delete, malloc, realloc, calloc, free, etc so that it will keep a record of the values of the memory being allocated, is it freed in the end or not, etc. Just like a memory leak detector / profiler. And it is native in Visual C++ (AFAIK).
Originally Posted by
Elysia
It seems to me that you would have to push the macro, undef it, then pop the macro where appropriate. Macros are evil; which is also why they are typically avoided.
That would mean re-writing the whole 400+ header and source files with 2000+ lines of code each (in average). Great.
Is there any other easier way?
Thanks again.