Guilhem.
--- Begin Message --- Hi,
I've been trying to make azureus work with kaffe and apparently they use an hidden feature of sun's jdk: it is capable to do mark(Integer.MAX_VALUE). So I modified the mark() logic to be able to allocate buffers incrementally.
Please review.
Here is the changelog:
2004-03-06 Guilhem Lavaux <[EMAIL PROTECTED]>
* libraries/javalib/java/io/BufferedInputStream.java (mark, refill) Make an incremental mark buffer allocation. New field marktarget, CHUNKSIZE.
Cheers, Guilhem.Index: java/io/BufferedInputStream.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/io/BufferedInputStream.java,v retrieving revision 1.10 diff -u -r1.10 BufferedInputStream.java --- java/io/BufferedInputStream.java 22 Jan 2002 22:26:59 -0000 1.10 +++ java/io/BufferedInputStream.java 6 Mar 2004 18:29:28 -0000 @@ -103,6 +103,19 @@ protected int marklimit = 0; /** + * This is the maximum size we have to allocate for the mark buffer. + * This number may be huge (Integer.MAX_VALUE). The class will continue + * to allocate new chunks (specified by <code>CHUNKSIZE</code>) until the + * the size specified by this field is achieved. + */ + protected int marktarget = 0; + + /** + * This is the number of bytes to allocate to reach marktarget. + */ + static final protected int CHUNKSIZE = 1024; + + /** * This method initializes a new <code>BufferedInputStream</code> that will * read from the specified subordinate stream with a default buffer size * of 2048 bytes @@ -183,7 +196,9 @@ */ public synchronized void mark(int readlimit) { - marklimit = readlimit; + marktarget = marklimit = readlimit; + if (marklimit > CHUNKSIZE) + marklimit = CHUNKSIZE; markpos = pos; } @@ -337,13 +352,16 @@ pos -= markpos; markpos = 0; } - else if (marklimit >= buf.length) // BTW, markpos == 0 + else if (marktarget >= buf.length && marklimit < marktarget) // BTW, markpos == 0 { // Need to grow the buffer now to have room for marklimit bytes. // Note that the new buffer is one greater than marklimit. // This is so that there will be one byte past marklimit to be read // before having to call refill again, thus allowing marklimit to be // invalidated. That way refill doesn't have to check marklimit. + marklimit += CHUNKSIZE; + if (marklimit >= marktarget) + marklimit = marktarget; byte[] newbuf = new byte[marklimit + 1]; System.arraycopy(buf, 0, newbuf, 0, count); buf = newbuf;pgp00000.pgp
Description: PGP signature
--- End Message ---
pgp00001.pgp
Description: PGP signature_______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath