[patch] String.getBytes()

Per Bothner bothner@cygnus.com
Wed Apr 21 13:27:00 GMT 1999


I'm rather sick now, so I may not be thinking too clearly,
but your patch seems wrong to me. I think something like
the following (untested) is right. Basically, `buflen'
should be the allocated size of `buffer', while `bufpos'
is the number of bytes written to it.
Index: natString.cc
===================================================================
RCS file: /cvs/cvsfiles/devo/libjava/java/lang/natString.cc,v
retrieving revision 1.24
diff -u -r1.24 natString.cc
--- natString.cc	1999年04月21日 19:40:27	1.24
+++ natString.cc	1999年04月21日 20:23:52
@@ -473,9 +473,11 @@
 {
 converter->setOutput(buffer, bufpos);
 int converted = converter->write(this, offset, todo, NULL);
+ bufpos = converter->count;
 if (converted == 0)
 	{
-	 jbyteArray newbuffer = JvNewByteArray(2 * buflen);
+	 buflen = 2 * buflen;
+	 jbyteArray newbuffer = JvNewByteArray(buflen);
 	 memcpy (elements (newbuffer), elements (buffer), bufpos);
 	 buffer = newbuffer;
 	}
	--Per Bothner
Cygnus Solutions bothner@cygnus.com http://www.cygnus.com/~bothner


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /