From 9ee0ceadae7cc5cdedf675f515b653cd626af132 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 10 Sep 2009 16:09:29 -0700 Subject: Several small native code fixes. * Don't throw OutOfMemoryError manually in Adler32/CRC32: the VM does that for us if GetPrimitiveArrayCritical needs, but fails, to allocate memory. * Don't use anything but NULL for the "iscopy" argument to Get*ArrayElements. The other users of this argument (removed earlier this week) were under the mistaken impression that it's an "in" parameter rather than an "out" parameter, and since these remaining callers aren't actually using the result, let's remove the cruft. * Move the null check in harmony_io_openImpl for "path" to come *before* the first dereference. * Make harmony_io_ttyReadImpl just delegate to harmony_io_readImpl since, apart from the zero-length read check, they were identical. * Remove the dead function throwIOExceptionStr from the OpenSSLSessionImpl native code. Tested on sapphire-eng. --- archive/src/main/native/java_util_zip_Adler32.c | 9 ++------- archive/src/main/native/java_util_zip_CRC32.c | 8 ++------ 2 files changed, 4 insertions(+), 13 deletions(-) (limited to 'archive/src') diff --git a/archive/src/main/native/java_util_zip_Adler32.c b/archive/src/main/native/java_util_zip_Adler32.c index 1b02a11..0fcf549 100644 --- a/archive/src/main/native/java_util_zip_Adler32.c +++ b/archive/src/main/native/java_util_zip_Adler32.c @@ -25,16 +25,11 @@ Java_java_util_zip_Adler32_updateImpl (JNIEnv * env, jobject recv, jbyteArray buf, int off, int len, jlong crc) { - jbyte *b; - jboolean isCopy; - jlong result; - - b = (*env)->GetPrimitiveArrayCritical (env, buf, &isCopy); + jbyte* b = (*env)->GetPrimitiveArrayCritical (env, buf, NULL); if (b == NULL) { - throwNewOutOfMemoryError(env, ""); return 0; } - result = (jlong) adler32 ((uLong) crc, (Bytef *) (b + off), (uInt) len); + jlong result = (jlong) adler32 ((uLong) crc, (Bytef *) (b + off), (uInt) len); (*env)->ReleasePrimitiveArrayCritical (env, buf, b, JNI_ABORT); return result; diff --git a/archive/src/main/native/java_util_zip_CRC32.c b/archive/src/main/native/java_util_zip_CRC32.c index cee25e5..fe50fca 100644 --- a/archive/src/main/native/java_util_zip_CRC32.c +++ b/archive/src/main/native/java_util_zip_CRC32.c @@ -25,15 +25,11 @@ Java_java_util_zip_CRC32_updateImpl (JNIEnv * env, jobject recv, jbyteArray buf, int off, int len, jlong crc) { - jbyte *b; - jlong result; - - b = ((*env)->GetPrimitiveArrayCritical (env, buf, 0)); + jbyte* b = ((*env)->GetPrimitiveArrayCritical (env, buf, 0)); if (b == NULL) { - throwNewOutOfMemoryError(env, ""); return -1; } - result = crc32 ((uLong) crc, (Bytef *) (b + off), (uInt) len); + jlong result = crc32 ((uLong) crc, (Bytef *) (b + off), (uInt) len); ((*env)->ReleasePrimitiveArrayCritical (env, buf, b, JNI_ABORT)); return result; } -- cgit v1.1