aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/main.cpp2
-rw-r--r--common/scummsys.h13
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