summaryrefslogtreecommitdiffstats
path: root/archive/src
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2009-09-10 16:09:29 -0700
committerElliott Hughes <enh@google.com>2009-09-10 16:09:29 -0700
commit9ee0ceadae7cc5cdedf675f515b653cd626af132 (patch)
tree6adba8b3cd73835610b5fe53180f0407f28d8b04 /archive/src
parent1826734268ac8ec3501d7e141239db12de76df15 (diff)
downloadlibcore-9ee0ceadae7cc5cdedf675f515b653cd626af132.zip
libcore-9ee0ceadae7cc5cdedf675f515b653cd626af132.tar.gz
libcore-9ee0ceadae7cc5cdedf675f515b653cd626af132.tar.bz2
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.
Diffstat (limited to 'archive/src')
-rw-r--r--archive/src/main/native/java_util_zip_Adler32.c9
-rw-r--r--archive/src/main/native/java_util_zip_CRC32.c8
2 files changed, 4 insertions, 13 deletions
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;
}