Skip to content

Commit

Permalink
Use original compressed/uncompressed buffer's position. (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya authored Oct 20, 2021
1 parent f3d7c11 commit 19cfc8d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/org/xerial/snappy/Snappy.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,13 @@ public static int compress(ByteBuffer uncompressed, ByteBuffer compressed)
// output: compressed
int uPos = uncompressed.position();
int uLen = uncompressed.remaining();
int cPos = compressed.position();
int compressedSize = impl.rawCompress(uncompressed, uPos, uLen, compressed,
compressed.position());
cPos);

// pos limit
// [ ......BBBBBBB.........]
compressed.limit(compressed.position() + compressedSize);
compressed.limit(cPos + compressedSize);

return compressedSize;
}
Expand Down Expand Up @@ -545,12 +546,13 @@ public static int uncompress(ByteBuffer compressed, ByteBuffer uncompressed)

int cPos = compressed.position();
int cLen = compressed.remaining();
int uPos = uncompressed.position();

// pos limit
// [ ......UUUUUU.........]
int decompressedSize = impl.rawUncompress(compressed, cPos, cLen, uncompressed,
uncompressed.position());
uncompressed.limit(uncompressed.position() + decompressedSize);
uPos);
uncompressed.limit(uPos + decompressedSize);

return decompressedSize;
}
Expand Down

0 comments on commit 19cfc8d

Please sign in to comment.