diff --git a/src/main/java/org/xerial/snappy/SnappyNative.cpp b/src/main/java/org/xerial/snappy/SnappyNative.cpp index f3d1f51..78af982 100755 --- a/src/main/java/org/xerial/snappy/SnappyNative.cpp +++ b/src/main/java/org/xerial/snappy/SnappyNative.cpp @@ -270,6 +270,19 @@ JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressed return ret; } +JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressedBuffer__JJJ + (JNIEnv * env, jobject self, jlong inputAddr, jlong offset, jlong length) +{ + if(inputAddr == 0) { + // out of memory + throw_exception(env, self, 4); + return 0; + } + bool ret = snappy::IsValidCompressedBuffer((char*) (inputAddr + offset), (size_t) length); + return ret; +} + + JNIEXPORT void JNICALL Java_org_xerial_snappy_SnappyNative_arrayCopy (JNIEnv * env, jobject self, jobject input, jint offset, jint length, jobject output, jint output_offset) { diff --git a/src/main/java/org/xerial/snappy/SnappyNative.h b/src/main/java/org/xerial/snappy/SnappyNative.h index 477d30a..d1f3e58 100755 --- a/src/main/java/org/xerial/snappy/SnappyNative.h +++ b/src/main/java/org/xerial/snappy/SnappyNative.h @@ -111,6 +111,14 @@ JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressed JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressedBuffer__Ljava_lang_Object_2II (JNIEnv *, jobject, jobject, jint, jint); +/* + * Class: org_xerial_snappy_SnappyNative + * Method: isValidCompressedBuffer + * Signature: (JJJ)Z + */ +JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressedBuffer__JJJ + (JNIEnv *, jobject, jlong, jlong, jlong); + /* * Class: org_xerial_snappy_SnappyNative * Method: arrayCopy diff --git a/src/main/java/org/xerial/snappy/SnappyNative.java b/src/main/java/org/xerial/snappy/SnappyNative.java index 7e9dbb2..b95e213 100755 --- a/src/main/java/org/xerial/snappy/SnappyNative.java +++ b/src/main/java/org/xerial/snappy/SnappyNative.java @@ -76,6 +76,8 @@ public class SnappyNative public native boolean isValidCompressedBuffer(Object input, int offset, int len) throws IOException; + public native boolean isValidCompressedBuffer(long inputAddr, long offset, long len) throws IOException; + public native void arrayCopy(Object src, int offset, int byteLength, Object dest, int dOffset) throws IOException; public void throw_error(int errorCode) throws IOException { diff --git a/src/main/resources/org/xerial/snappy/native/Mac/x86_64/libsnappyjava.jnilib b/src/main/resources/org/xerial/snappy/native/Mac/x86_64/libsnappyjava.jnilib index 392e03b..b9a2085 100755 Binary files a/src/main/resources/org/xerial/snappy/native/Mac/x86_64/libsnappyjava.jnilib and b/src/main/resources/org/xerial/snappy/native/Mac/x86_64/libsnappyjava.jnilib differ