开发者

Checking heap integrity when _DEBUG is not defined?

I wish to create a build of a project constructed so that it is identical to the release build, except that the debug version of the default allocator is used (with canary checks on alloc/free and so on). The compiler/CRT is Visual Studio 2010.

Reading the documentation for the CRT it seems that _DEBUG needs to be defined for calls to _CrtCheckMemory(), _malloc_dbg(), etc. to not be removed. I d开发者_运维知识库o not wish to enable the _DEBUG define since this will influence more than the allocator.

Is there a way to use the CRT debug allocator without having _DEBUG defined?


_malloc_dbg() requires the debug runtime, the debug runtime requires _DEBUG - So no, you can't do this.


You could find out the name of the malloc call that is used when _DEBUG is defined, and manually define malloc to use that instead?

Same with new if you're using c++, you could create a global override to the debug version

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜