This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Patch: zero allocated memory
- To: Java Patch List <java-patches at sourceware dot cygnus dot com>
- Subject: Patch: zero allocated memory
- From: Tom Tromey <tromey at cygnus dot com>
- Date: 20 Feb 2000 22:13:22 -0700
- Reply-To: tromey at cygnus dot com
I'm committing this patch. We've defined our memory allocation
interfaces to return cleared memory. This fixes one we missed.
2000-02-20 Tom Tromey <tromey@cygnus.com>
* boehm.cc (_Jv_AllocBytes): Clear returned memory.
Tom
Index: boehm.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/boehm.cc,v
retrieving revision 1.13
diff -u -r1.13 boehm.cc
--- boehm.cc 2000/01/21 23:50:30 1.13
+++ boehm.cc 2000/02/21 02:51:54
@@ -321,7 +321,14 @@
void *
_Jv_AllocBytes (jsize size)
{
- return GC_GENERIC_MALLOC (size, PTRFREE);
+ void *r = GC_GENERIC_MALLOC (size, PTRFREE);
+ // We have to explicitly zero memory here, as the GC doesn't
+ // guarantee that PTRFREE allocations are zeroed. Note that we
+ // don't have to do this for other allocation types because we set
+ // the `ok_init' flag in the type descriptor.
+ if (r != NULL)
+ memset (r, 0, size);
+ return r;
}
static void