mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 05:26:58 +00:00
Compile memory heap corruption detection code with _DEBUG_MEM and define it by default (for now)
svn path=/trunk/; revision=28068
This commit is contained in:
parent
8026c569b2
commit
683519ff1c
|
@ -6,6 +6,7 @@
|
|||
<define name="_WIN32_WINNT">0x0501</define>
|
||||
<define name="UNICODE" />
|
||||
<define name="_UNICODE" />
|
||||
<define name="_DEBUG_MEM" />
|
||||
<pch>precomp.h</pch>
|
||||
<compilationunit name="unit.c">
|
||||
<file>alias.c</file>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <precomp.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#ifdef _DEBUG_MEM
|
||||
|
||||
#define REDZONE_SIZE 32
|
||||
#define REDZONE_LEFT 0x78
|
||||
|
@ -63,6 +63,7 @@ redzone_err(const char *msg, palloc_info info, void *ptr, const char *file, int
|
|||
DbgPrint(" Block: 0x%p Size: %lu\n", ptr, info->size);
|
||||
DbgPrint(" Allocated from %s:%d\n", info->file, info->line);
|
||||
DbgPrint(" Detected at: %s:%d\n", file, line);
|
||||
ASSERT(FALSE);
|
||||
ExitProcess(1);
|
||||
}
|
||||
|
||||
|
@ -131,6 +132,16 @@ cmd_free_dbg(void *ptr, const char *file, int line)
|
|||
free(ptr);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_checkbuffer_dbg(void *ptr, const char *file, int line)
|
||||
{
|
||||
if (ptr != NULL)
|
||||
{
|
||||
ptr = get_base_ptr(ptr);
|
||||
check_redzone(ptr, file, line);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cmd_exit(int code)
|
||||
{
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#ifdef _DEBUG
|
||||
#ifdef _DEBUG_MEM
|
||||
|
||||
#define cmd_alloc(size) cmd_alloc_dbg(size, __FILE__, __LINE__)
|
||||
#define cmd_realloc(ptr,size) cmd_realloc_dbg(ptr, size, __FILE__, __LINE__)
|
||||
#define cmd_free(ptr) cmd_free_dbg(ptr, __FILE__, __LINE__)
|
||||
#define cmd_checkbuffer(ptr) cmd_checkbuffer_dbg(ptr, __FILE__, __LINE__)
|
||||
|
||||
void *
|
||||
cmd_alloc_dbg(size_t size, const char *file, int line);
|
||||
|
@ -13,10 +14,14 @@ cmd_realloc_dbg(void *ptr, size_t size, const char *file, int line);
|
|||
void
|
||||
cmd_free_dbg(void *ptr, const char *file, int line);
|
||||
|
||||
void
|
||||
cmd_checkbuffer_dbg(void *ptr, const char *file, int line);
|
||||
|
||||
#else
|
||||
|
||||
#define cmd_alloc(size) malloc(size)
|
||||
#define cmd_realloc(ptr,size) realloc(ptr, size)
|
||||
#define cmd_free(ptr) free(ptr)
|
||||
#define cmd_checkbuffer(ptr)
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue