[Scummvm-cvs-logs] CVS: scummvm/common main.cpp,1.26,1.27 scummsys.h,1.22,1.23
Max Horn
fingolfin at users.sourceforge.net
Tue May 20 05:34:05 CEST 2003
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv6398
Modified Files:
main.cpp scummsys.h
Log Message:
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.
Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/main.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- main.cpp 30 Apr 2003 12:43:54 -0000 1.26
+++ main.cpp 20 May 2003 12:25:11 -0000 1.27
@@ -234,7 +234,7 @@
#ifndef __PALM_OS__
void *operator new(size_t size) {
- return calloc(size, 1);
+ return memset(malloc(size), 0xE7, size);
}
void operator delete(void *ptr) {
Index: scummsys.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/scummsys.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- scummsys.h 18 May 2003 13:37:14 -0000 1.22
+++ scummsys.h 20 May 2003 12:25:11 -0000 1.23
@@ -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
More information about the Scummvm-git-logs
mailing list