Skip to content

Commit

Permalink
Revert the native method name LZ4_compress back to LZ4_compress_limit…
Browse files Browse the repository at this point in the history
…edOutput for backward compatibility
  • Loading branch information
odaira committed Nov 7, 2017
1 parent d95bd53 commit 6d50fd7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/java/net/jpountz/lz4/LZ4JNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ enum LZ4JNI {
}

static native void init();
static native int LZ4_compress(byte[] srcArray, ByteBuffer srcBuffer, int srcOff, int srcLen, byte[] destArray, ByteBuffer destBuffer, int destOff, int maxDestLen);
static native int LZ4_compress_limitedOutput(byte[] srcArray, ByteBuffer srcBuffer, int srcOff, int srcLen, byte[] destArray, ByteBuffer destBuffer, int destOff, int maxDestLen);
static native int LZ4_compressHC(byte[] srcArray, ByteBuffer srcBuffer, int srcOff, int srcLen, byte[] destArray, ByteBuffer destBuffer, int destOff, int maxDestLen, int compressionLevel);
static native int LZ4_decompress_fast(byte[] srcArray, ByteBuffer srcBuffer, int srcOff, byte[] destArray, ByteBuffer destBuffer, int destOff, int destLen);
static native int LZ4_decompress_safe(byte[] srcArray, ByteBuffer srcBuffer, int srcOff, int srcLen, byte[] destArray, ByteBuffer destBuffer, int destOff, int maxDestLen);
Expand Down
4 changes: 2 additions & 2 deletions src/java/net/jpountz/lz4/LZ4JNICompressor.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class LZ4JNICompressor extends LZ4Compressor {
public int compress(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff, int maxDestLen) {
checkRange(src, srcOff, srcLen);
checkRange(dest, destOff, maxDestLen);
final int result = LZ4JNI.LZ4_compress(src, null, srcOff, srcLen, dest, null, destOff, maxDestLen);
final int result = LZ4JNI.LZ4_compress_limitedOutput(src, null, srcOff, srcLen, dest, null, destOff, maxDestLen);
if (result <= 0) {
throw new LZ4Exception("maxDestLen is too small");
}
Expand Down Expand Up @@ -64,7 +64,7 @@ public int compress(ByteBuffer src, int srcOff, int srcLen, ByteBuffer dest, int
destBuf = dest;
}

final int result = LZ4JNI.LZ4_compress(srcArr, srcBuf, srcOff, srcLen, destArr, destBuf, destOff, maxDestLen);
final int result = LZ4JNI.LZ4_compress_limitedOutput(srcArr, srcBuf, srcOff, srcLen, destArr, destBuf, destOff, maxDestLen);
if (result <= 0) {
throw new LZ4Exception("maxDestLen is too small");
}
Expand Down
8 changes: 6 additions & 2 deletions src/jni/net_jpountz_lz4_LZ4JNI.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ static void throw_OOM(JNIEnv *env) {

/*
* Class: net_jpountz_lz4_LZ4JNI
* Method: LZ4_compress
* Method: LZ4_compress_limitedOutput
* Signature: ([BLjava/nio/ByteBuffer;II[BLjava/nio/ByteBuffer;II)I
*
* Though LZ4_compress_limitedOutput is no longer called as it was deprecated,
* keep the method name of LZ4_compress_limitedOutput for backward compatibility,
* so that the old JNI bindings in src/resources can still be used.
*/
JNIEXPORT jint JNICALL Java_net_jpountz_lz4_LZ4JNI_LZ4_1compress
JNIEXPORT jint JNICALL Java_net_jpountz_lz4_LZ4JNI_LZ4_1compress_1limitedOutput
(JNIEnv *env, jclass cls, jbyteArray srcArray, jobject srcBuffer, jint srcOff, jint srcLen, jbyteArray destArray, jobject destBuffer, jint destOff, jint maxDestLen) {

char* in;
Expand Down

0 comments on commit 6d50fd7

Please sign in to comment.