Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allocate the right size buffer.

  • Loading branch information...
commit 8caee4da162daa6eb1079c976f407fb9224f4343 1 parent 1cc535f
@chirino chirino authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 leveldb/src/main/java/org/iq80/leveldb/util/Snappy.java
View
4 leveldb/src/main/java/org/iq80/leveldb/util/Snappy.java
@@ -92,9 +92,11 @@ public int uncompress(ByteBuffer compressed, ByteBuffer uncompressed) throws IOE
output = uncompressed.array();
outputOffset = uncompressed.arrayOffset() + uncompressed.position();
} else {
- output = new byte[uncompressed.capacity()-uncompressed.position()];
+ int t = org.iq80.snappy.Snappy.getUncompressedLength(input, inputOffset);
+ output = new byte[t];
outputOffset = 0;
}
+
int count = org.iq80.snappy.Snappy.uncompress(input, inputOffset, length, output, outputOffset);
if( uncompressed.hasArray() ) {
uncompressed.limit(uncompressed.position()+count);
Please sign in to comment.
Something went wrong with that request. Please try again.