I want to "hide" these memory allocations from Visual C++'s CRT memory tracing functionality, and have found a neat little trick for doing so, using STLSoft's scoped_handle, as follows:
#if defined(_DEBUG) && \
defined(STLSOFT_COMPILER_IS_MSVC)
int prev = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
_CrtSetDbgFlag(prev & ~_CRTDBG_ALLOC_MEM_DF);
stlsoft::scoped_handle
#endif
. . . // allocate memory that wont' be recorded as leaks
} // MSVCRT settings reset here
No comments:
Post a Comment