mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-25 09:58:11 +01:00
makeIntArray takes array of initial values
This commit is contained in:
parent
df7a445a9e
commit
ecd5667cf0
2 changed files with 9 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
Loading…
Reference in a new issue