Chromium Code Reviews| Index: base/android/jni_array.cc |
| diff --git a/base/android/jni_array.cc b/base/android/jni_array.cc |
| index bc922f883c2f8c296fbbfdd4a2590afc2fb11bc9..0b7ce5d1448e35e8060f94eb441926b4d223a06e 100644 |
| --- a/base/android/jni_array.cc |
| +++ b/base/android/jni_array.cc |
| @@ -229,11 +229,27 @@ void JavaArrayOfByteArrayToStringVector( |
| env, static_cast<jbyteArray>( |
| env->GetObjectArrayElement(array, i))); |
| jsize bytes_len = env->GetArrayLength(bytes_array.obj()); |
| - jbyte* bytes = env->GetByteArrayElements(bytes_array.obj(), NULL); |
| + jbyte* bytes = env->GetByteArrayElements(bytes_array.obj(), nullptr); |
| (*out)[i].assign(reinterpret_cast<const char*>(bytes), bytes_len); |
| env->ReleaseByteArrayElements(bytes_array.obj(), bytes, JNI_ABORT); |
| } |
| } |
| +void JavaArrayOfIntArrayToIntVector( |
| + JNIEnv* env, |
| + jobjectArray array, |
| + std::vector<std::vector<int>>* out) { |
| + DCHECK(out); |
| + size_t len = SafeGetArrayLength(env, array); |
| + out->resize(len); |
| + for (size_t i = 0; i < len; ++i) { |
| + ScopedJavaLocalRef<jintArray> int_array( |
| + env, static_cast<jintArray>(env->GetObjectArrayElement(array, i))); |
| + jint* ints = env->GetIntArrayElements(int_array.obj(), nullptr); |
|
Dmitry Skiba
2015/10/30 16:46:19
Hmm, do we really need to get 'ints' here? It does
Theresa
2015/10/30 17:01:15
It's used to release the int array elements on lin
Dmitry Skiba
2015/10/30 17:17:32
Yes, but 'ints' is not read from. For example in t
Theresa
2015/10/30 17:25:28
I included this code because a new jintArray is cr
Dmitry Skiba
2015/10/30 17:37:26
There are two ways of accessing array elements: Ge
|
| + JavaIntArrayToIntVector(env, int_array.obj(), &((*out)[i])); |
| + env->ReleaseIntArrayElements(int_array.obj(), ints, JNI_ABORT); |
| + } |
| +} |
| + |
| } // namespace android |
| } // namespace base |