diff options
author | Max Horn | 2003-05-20 12:25:11 +0000 |
---|---|---|
committer | Max Horn | 2003-05-20 12:25:11 +0000 |
commit | 0f64347b35430390e4a75d6d9d117e7924f800d3 (patch) | |
tree | 5075ab9a4182ef2473b160167167238d4764b25c | |
parent | 8d1110bfee983ad8e28f67564688eea872d8d4c1 (diff) | |
download | scummvm-rg350-0f64347b35430390e4a75d6d9d117e7924f800d3.tar.gz scummvm-rg350-0f64347b35430390e4a75d6d9d117e7924f800d3.tar.bz2 scummvm-rg350-0f64347b35430390e4a75d6d9d117e7924f800d3.zip |
replace our 'nice' new which sets memory to 0 with a nasty one which sets it to 0xE7. This should help finding any remaining places where we don't init member variables as we should.
svn-id: r7719
-rw-r--r-- | common/main.cpp | 2 | ||||
-rw-r--r-- | common/scummsys.h | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/common/main.cpp b/common/main.cpp index 2765c849d4..58b7b258fe 100644 --- a/common/main.cpp +++ b/common/main.cpp @@ -234,7 +234,7 @@ int main(int argc, char *argv[]) { #ifndef __PALM_OS__ void *operator new(size_t size) { - return calloc(size, 1); + return memset(malloc(size), 0xE7, size); } void operator delete(void *ptr) { diff --git a/common/scummsys.h b/common/scummsys.h index be4b821139..1ee3c00452 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -23,6 +23,7 @@ #define SCUMMSYS_H #include <stdlib.h> +#include <stdio.h> // TODO - use config.h, generated by configure #if defined(HAVE_CONFIG_H) @@ -432,6 +433,18 @@ #ifndef __PALM_OS__ void * operator new(size_t size); void operator delete(void *ptr); +// Temporary hack until we fully remove the new/delete operators: +// Since 'new' now returns a memory block inited to 0xE7E7E7E7 we might +// get some invocations of free() with that param. We check for those here. +// That allows us to set a debugger breakpoint to catch it. +inline void free_check(void *ptr) { + if ((uint)ptr == 0xE7E7E7E7UL) { + printf("ERROR: freeing 0xE7E7E7E7\n"); + exit(1); + } + free(ptr); +} +#define free(x) free_check(x) #endif #endif |