[ros-diffs] [weiden] 28068: Compile memory heap corruption detection code with _DEBUG_MEM and define it by default (for now)

weiden at svn.reactos.org weiden at svn.reactos.org
Wed Aug 1 14:04:49 CEST 2007


Author: weiden
Date: Wed Aug  1 16:04:49 2007
New Revision: 28068

URL: http://svn.reactos.org/svn/reactos?rev=28068&view=rev
Log:
Compile memory heap corruption detection code with _DEBUG_MEM and define it by default (for now)

Modified:
    trunk/reactos/base/shell/cmd/cmd.rbuild
    trunk/reactos/base/shell/cmd/cmddbg.c
    trunk/reactos/base/shell/cmd/cmddbg.h

Modified: trunk/reactos/base/shell/cmd/cmd.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.rbuild?rev=28068&r1=28067&r2=28068&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/cmd.rbuild (original)
+++ trunk/reactos/base/shell/cmd/cmd.rbuild Wed Aug  1 16:04:49 2007
@@ -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>

Modified: trunk/reactos/base/shell/cmd/cmddbg.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmddbg.c?rev=28068&r1=28067&r2=28068&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/cmddbg.c (original)
+++ trunk/reactos/base/shell/cmd/cmddbg.c Wed Aug  1 16:04:49 2007
@@ -1,6 +1,6 @@
 #include <precomp.h>
 
-#ifdef _DEBUG
+#ifdef _DEBUG_MEM
 
 #define REDZONE_SIZE  32
 #define REDZONE_LEFT 0x78
@@ -63,6 +63,7 @@
     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);
 }
 
@@ -132,6 +133,16 @@
 }
 
 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)
 {
     ExitProcess(code);

Modified: trunk/reactos/base/shell/cmd/cmddbg.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmddbg.h?rev=28068&r1=28067&r2=28068&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/cmddbg.h (original)
+++ trunk/reactos/base/shell/cmd/cmddbg.h Wed Aug  1 16:04:49 2007
@@ -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 @@
 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




More information about the Ros-diffs mailing list