Permalink
Browse files

Allocate the right size buffer.

  • Loading branch information...
1 parent 1cc535f commit 8caee4da162daa6eb1079c976f407fb9224f4343 @chirino chirino committed Dec 23, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 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);

0 comments on commit 8caee4d

Please sign in to comment.