Skip to content

Commit

Permalink
The total() method should return long instead of int (fixes issue #142)
Browse files Browse the repository at this point in the history
  • Loading branch information
romix committed Oct 22, 2013
1 parent a0da819 commit 859de2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/com/esotericsoftware/kryo/io/Input.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Input extends InputStream {
protected int position;
protected int capacity;
protected int limit;
protected int total;
protected long total;
protected char[] chars = new char[32];
protected InputStream inputStream;

Expand Down Expand Up @@ -91,7 +91,7 @@ public void setInputStream (InputStream inputStream) {
}

/** Returns the number of bytes read. */
public int total () {
public long total () {
return total + position;
}

Expand Down Expand Up @@ -565,7 +565,7 @@ private void readUtf8_slow (int charCount, int charIndex) {
charIndex++;
}
}

private String readAscii () {
byte[] buffer = this.buffer;
int end = position;
Expand Down
7 changes: 4 additions & 3 deletions src/com/esotericsoftware/kryo/io/Output.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
*
* @author Nathan Sweet <[email protected]> */
public class Output extends OutputStream {
protected int maxCapacity, total;
protected int maxCapacity;
protected long total;
protected int position;
protected int capacity;
protected byte[] buffer;
Expand Down Expand Up @@ -123,7 +124,7 @@ public void setPosition (int position) {
}

/** Returns the total number of bytes written. This may include bytes that have not been flushed. */
final public int total () {
final public long total () {
return total + position;
}

Expand Down Expand Up @@ -343,7 +344,7 @@ public void writeString (String value) throws KryoException {
if (charIndex < charCount) writeString_slow(value, charCount, charIndex);
}
}

/** Writes the length and CharSequence as UTF8, or null. The string can be read using {@link Input#readString()} or
* {@link Input#readStringBuilder()}.
* @param value May be null. */
Expand Down

0 comments on commit 859de2e

Please sign in to comment.