This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[BC] Patch (delayed): fix ioffsets goof
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 07 Oct 2004 17:02:26 -0600
- Subject: [BC] Patch (delayed): fix ioffsets goof
- Reply-to: tromey at redhat dot com
I will check this in once Andrew reopens the BC branch.
This fixes a goof introduced by me. We incorrectly compute the number
of bytes to copy when resizing the ioffsets array.
I discovered this when, on a whim, I ran valgrind on gij.
I suspect this bug may be the problem I saw with allocating ioffsets
and friends using the GC; I'm going to test that theory next.
It also occurs to me that we could have the compiler compute the
ideal ioffsets size and then optimistically start with that value.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* link.cc (find_iindex): Copy correct number of slots to new
ioffsets.
Index: link.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Attic/link.cc,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 link.cc
--- link.cc 6 Oct 2004 19:32:46 -0000 1.1.2.3
+++ link.cc 7 Oct 2004 23:01:09 -0000
@@ -746,7 +746,7 @@
int len = ifaces[j]->idt->iface.ioffsets[0];
if (i >= len)
{
- /* Resize ioffsets. */
+ // Resize ioffsets.
int newlen = 2 * len;
if (i >= newlen)
newlen = i + 3;
@@ -754,7 +754,8 @@
// FIXME: _Jv_AllocBytes
jshort *new_ioffsets = (jshort *) _Jv_Malloc (newlen
* sizeof(jshort));
- memcpy (&new_ioffsets[1], &old_ioffsets[1], len * sizeof (jshort));
+ memcpy (&new_ioffsets[1], &old_ioffsets[1],
+ (len - 1) * sizeof (jshort));
new_ioffsets[0] = newlen;
while (len < newlen)