diff options
author | Elliott Hughes <enh@google.com> | 2009-09-08 19:44:54 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2009-09-09 13:41:50 -0700 |
commit | 44550df73a4aff18af123c65c5fbc69c02cbb1bd (patch) | |
tree | f36aebe7e7365ca853d8b8a1538c609c9ffaee34 /x-net | |
parent | d87bb037ea1e7c877b9f81359a5d6675097e46de (diff) | |
download | libcore-44550df73a4aff18af123c65c5fbc69c02cbb1bd.zip libcore-44550df73a4aff18af123c65c5fbc69c02cbb1bd.tar.gz libcore-44550df73a4aff18af123c65c5fbc69c02cbb1bd.tar.bz2 |
Use Get*ArrayRegion/Set*ArrayRegion instead of Get*ArrayElements.
This fixes all instances in the networking code, but doesn't address similar
patterns, nor non-networking code. This seemed like a reasonably-sized
meaningful chunk. Tested on sapphire-eng.
Bug: 1639287
Diffstat (limited to 'x-net')
-rw-r--r-- | x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSessionImpl.cpp | 17 | ||||
-rw-r--r-- | x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_common.h | 5 |
2 files changed, 8 insertions, 14 deletions
diff --git a/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSessionImpl.cpp b/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSessionImpl.cpp index feae690..c79bfdf 100644 --- a/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSessionImpl.cpp +++ b/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSessionImpl.cpp @@ -150,20 +150,15 @@ static jint org_apache_harmony_xnet_provider_jsse_OpenSSLSessionImpl_deserialize */ static jbyteArray org_apache_harmony_xnet_provider_jsse_OpenSSLSessionImpl_getid(JNIEnv* env, jobject object) { - SSL_SESSION * ssl_session; - jbyteArray bytes; - jbyte *tmp; - - ssl_session = getSslSessionPointer(env, object); + SSL_SESSION* ssl_session = getSslSessionPointer(env, object); - bytes = env->NewByteArray(ssl_session->session_id_length); - if (bytes != NULL) { - tmp = env->GetByteArrayElements(bytes, NULL); - memcpy(tmp, ssl_session->session_id, ssl_session->session_id_length); - env->ReleaseByteArrayElements(bytes, tmp, 0); + jbyteArray result = env->NewByteArray(ssl_session->session_id_length); + if (result != NULL) { + jbyte* src = reinterpret_cast<jbyte*>(ssl_session->session_id); + env->SetByteArrayRegion(result, 0, ssl_session->session_id_length, src); } - return bytes; + return result; } /** diff --git a/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_common.h b/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_common.h index 9ed75be..409b4ec 100644 --- a/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_common.h +++ b/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_common.h @@ -76,9 +76,8 @@ static jobjectArray getcertificatebytes(JNIEnv* env, joa = NULL; break; } else { - jbyte *tmp = env->GetByteArrayElements(bytes, NULL); - memcpy(tmp, bptr->data, bptr->length); - env->ReleaseByteArrayElements(bytes, tmp, 0); + jbyte* src = reinterpret_cast<jbyte*>(bptr->data); + env->SetByteArrayRegion(bytes, 0, bptr->length, src); env->SetObjectArrayElement(joa, i, bytes); } } |