diff --git a/xwords4/android/andutils.c b/xwords4/android/andutils.c index 44be57ff4..712cd7682 100644 --- a/xwords4/android/andutils.c +++ b/xwords4/android/andutils.c @@ -168,14 +168,16 @@ getBool( JNIEnv* env, jobject obj, const char* name, XP_Bool* result ) } jintArray -makeIntArray( JNIEnv *env, int val ) +makeIntArray( JNIEnv *env, int siz, const jint* vals ) { - jintArray array = (*env)->NewIntArray( env, 1 ); + jintArray array = (*env)->NewIntArray( env, siz ); XP_ASSERT( !!array ); - jint* elems = (*env)->GetIntArrayElements( env, array, NULL ); - XP_ASSERT( !!elems ); - *elems = val; - (*env)->ReleaseIntArrayElements( env, array, elems, 0 ); + if ( !!vals ) { + jint* elems = (*env)->GetIntArrayElements( env, array, NULL ); + XP_ASSERT( !!elems ); + XP_MEMCPY( elems, vals, siz * sizeof(*elems) ); + (*env)->ReleaseIntArrayElements( env, array, elems, 0 ); + } return array; } diff --git a/xwords4/android/andutils.h b/xwords4/android/andutils.h index 540e0a58a..99dff89ab 100644 --- a/xwords4/android/andutils.h +++ b/xwords4/android/andutils.h @@ -22,7 +22,7 @@ bool getString( JNIEnv* env, jobject jlp, const char* name, XP_UCHAR* buf, bool getObject( JNIEnv* env, jobject obj, const char* name, const char* sig, jobject* ret ); -jintArray makeIntArray( JNIEnv *env, int val ); +jintArray makeIntArray( JNIEnv *env, int size, const jint* vals ); int getIntFromArray( JNIEnv* env, jintArray arr, bool del ); /* Note: jmethodID can be cached. Should not look up more than once. */