Skip to content

Commit bb156dc

Browse files
committed
Document behaviour when decompressing and originalSize does not match
Addresses #239
1 parent 32b337a commit bb156dc

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/main/java/com/github/luben/zstd/Zstd.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,9 @@ public static ByteBuffer compress(ByteBuffer srcBuff, ZstdDictCompress dict) {
10871087
* Decompress data
10881088
*
10891089
* @param src the source buffer
1090-
* @param originalSize the maximum size of the uncompressed data
1090+
* @param originalSize the maximum size of the uncompressed data.
1091+
* If originaSize is greater than the actuall uncompressed size, additional memory copy going to happen.
1092+
* If originalSize is smaller than the uncompressed size, ZstdExeption will be thrown.
10911093
* @return byte array with the decompressed data
10921094
*/
10931095
public static byte[] decompress(byte[] src, int originalSize) {

src/main/java/com/github/luben/zstd/ZstdDecompressCtx.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,15 @@ public int decompress(byte[] dst, byte[] src) {
273273
return decompressByteArray(dst, 0, dst.length, src, 0, src.length);
274274
}
275275

276+
/**
277+
* Decompress data
278+
*
279+
* @param src the source buffer
280+
* @param originalSize the maximum size of the uncompressed data.
281+
* If originaSize is greater than the actuall uncompressed size, additional memory copy going to happen.
282+
* If originalSize is smaller than the uncompressed size, ZstdExeption will be thrown.
283+
* @return byte array with the decompressed data
284+
*/
276285
public byte[] decompress(byte[] src, int originalSize) throws ZstdException {
277286
byte[] dst = new byte[originalSize];
278287
int size = decompress(dst, src);

0 commit comments

Comments
 (0)