mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
Merge branch 'android_branch' into android_dictdb
Conflicts: xwords4/android/XWords4/jni/jniutlswrapper.c
This commit is contained in:
commit
75398389b3
8 changed files with 96 additions and 101 deletions
|
@ -141,7 +141,7 @@ andMakeBitmap( AndDictionaryCtxt* ctxt, XP_U8 const** ptrp,
|
|||
JNIEnv* env = ctxt->env;
|
||||
jobject tmp = and_util_makeJBitmap( ctxt->jniutil, nCols, nRows, colors );
|
||||
bitmap = (*env)->NewGlobalRef( env, tmp );
|
||||
(*env)->DeleteLocalRef( env, tmp );
|
||||
deleteLocalRef( env, tmp );
|
||||
XP_FREE( ctxt->super.mpool, colors );
|
||||
#endif
|
||||
}
|
||||
|
@ -242,13 +242,13 @@ splitFaces_via_java( JNIEnv* env, AndDictionaryCtxt* ctxt, const XP_U8* ptr,
|
|||
XP_MEMCPY( &facesBuf[indx], bytes, nBytes );
|
||||
}
|
||||
(*env)->ReleaseStringUTFChars( env, jstr, bytes );
|
||||
(*env)->DeleteLocalRef( env, jstr );
|
||||
deleteLocalRef( env, jstr );
|
||||
|
||||
indx += nBytes;
|
||||
facesBuf[indx++] = '\0';
|
||||
XP_ASSERT( indx < VSIZE(facesBuf) );
|
||||
}
|
||||
(*env)->DeleteLocalRef( env, jstrarr );
|
||||
deleteLocalRef( env, jstrarr );
|
||||
|
||||
XP_UCHAR* faces = (XP_UCHAR*)XP_CALLOC( ctxt->super.mpool, indx );
|
||||
const XP_UCHAR** ptrs = (const XP_UCHAR**)
|
||||
|
@ -353,7 +353,7 @@ parseDict( AndDictionaryCtxt* ctxt, XP_U8 const* ptr, XP_U32 dictLength,
|
|||
ptr, end - ptr );
|
||||
}
|
||||
XP_UCHAR* md5Sum = getStringCopy( MPPARM(ctxt->super.mpool) env, jsum );
|
||||
(*env)->DeleteLocalRef( env, jsum );
|
||||
deleteLocalRef( env, jsum );
|
||||
if ( NULL == ctxt->super.md5Sum ) {
|
||||
ctxt->super.md5Sum = md5Sum;
|
||||
} else {
|
||||
|
@ -539,12 +539,9 @@ makeDicts( MPFORMAL JNIEnv *env, JNIUtilCtxt* jniutil,
|
|||
dict = makeDict( MPPARM(mpool) env, jniutil, jname, jdict,
|
||||
jpath, jlang, false );
|
||||
XP_ASSERT( !!dict );
|
||||
(*env)->DeleteLocalRef( env, jdict );
|
||||
(*env)->DeleteLocalRef( env, jname );
|
||||
}
|
||||
if ( NULL != jpath) {
|
||||
(*env)->DeleteLocalRef( env, jpath );
|
||||
deleteLocalRefs( env, jdict, jname, DELETE_NO_REF );
|
||||
}
|
||||
deleteLocalRef( env, jpath );
|
||||
}
|
||||
if ( 0 == ii ) {
|
||||
*dictp = dict;
|
||||
|
|
|
@ -84,7 +84,7 @@ getInt( JNIEnv* env, jobject obj, const char* name )
|
|||
jfieldID fid = (*env)->GetFieldID( env, cls, name, "I");
|
||||
XP_ASSERT( !!fid );
|
||||
int result = (*env)->GetIntField( env, obj, fid );
|
||||
(*env)->DeleteLocalRef( env, cls );
|
||||
deleteLocalRef( env, cls );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ setInt( JNIEnv* env, jobject obj, const char* name, int value )
|
|||
jfieldID fid = (*env)->GetFieldID( env, cls, name, "I");
|
||||
XP_ASSERT( !!fid );
|
||||
(*env)->SetIntField( env, obj, fid, value );
|
||||
(*env)->DeleteLocalRef( env, cls );
|
||||
deleteLocalRef( env, cls );
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -109,7 +109,7 @@ setBool( JNIEnv* env, jobject obj, const char* name, bool value )
|
|||
(*env)->SetBooleanField( env, obj, fid, value );
|
||||
success = true;
|
||||
}
|
||||
(*env)->DeleteLocalRef( env, cls );
|
||||
deleteLocalRef( env, cls );
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -120,13 +120,13 @@ setString( JNIEnv* env, jobject obj, const char* name, const XP_UCHAR* value )
|
|||
bool success = false;
|
||||
jclass cls = (*env)->GetObjectClass( env, obj );
|
||||
jfieldID fid = (*env)->GetFieldID( env, cls, name, "Ljava/lang/String;" );
|
||||
(*env)->DeleteLocalRef( env, cls );
|
||||
deleteLocalRef( env, cls );
|
||||
|
||||
if ( 0 != fid ) {
|
||||
jstring str = (*env)->NewStringUTF( env, value );
|
||||
(*env)->SetObjectField( env, obj, fid, str );
|
||||
success = true;
|
||||
(*env)->DeleteLocalRef( env, str );
|
||||
deleteLocalRef( env, str );
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@ -148,11 +148,11 @@ getString( JNIEnv* env, jobject obj, const char* name, XP_UCHAR* buf,
|
|||
const char* chars = (*env)->GetStringUTFChars( env, jstr, NULL );
|
||||
XP_MEMCPY( buf, chars, len );
|
||||
(*env)->ReleaseStringUTFChars( env, jstr, chars );
|
||||
(*env)->DeleteLocalRef( env, jstr );
|
||||
deleteLocalRef( env, jstr );
|
||||
}
|
||||
buf[len] = '\0';
|
||||
|
||||
(*env)->DeleteLocalRef( env, cls );
|
||||
deleteLocalRef( env, cls );
|
||||
}
|
||||
|
||||
XP_UCHAR*
|
||||
|
@ -180,7 +180,7 @@ getObject( JNIEnv* env, jobject obj, const char* name, const char* sig,
|
|||
*ret = (*env)->GetObjectField( env, obj, fid );
|
||||
XP_ASSERT( !!*ret );
|
||||
|
||||
(*env)->DeleteLocalRef( env, cls );
|
||||
deleteLocalRef( env, cls );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ setObject( JNIEnv* env, jobject obj, const char* name, const char* sig,
|
|||
XP_ASSERT( !!fid );
|
||||
(*env)->SetObjectField( env, obj, fid, val );
|
||||
|
||||
(*env)->DeleteLocalRef( env, cls );
|
||||
deleteLocalRef( env, cls );
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -206,7 +206,7 @@ getBool( JNIEnv* env, jobject obj, const char* name )
|
|||
jfieldID fid = (*env)->GetFieldID( env, cls, name, "Z");
|
||||
XP_ASSERT( !!fid );
|
||||
result = (*env)->GetBooleanField( env, obj, fid );
|
||||
(*env)->DeleteLocalRef( env, cls );
|
||||
deleteLocalRef( env, cls );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ getIntFromArray( JNIEnv* env, jintArray arr, bool del )
|
|||
int result = ints[0];
|
||||
(*env)->ReleaseIntArrayElements( env, arr, ints, 0);
|
||||
if ( del ) {
|
||||
(*env)->DeleteLocalRef( env, arr );
|
||||
deleteLocalRef( env, arr );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -277,14 +277,13 @@ makeStringArray( JNIEnv *env, int siz, const XP_UCHAR** vals )
|
|||
jclass clas = (*env)->FindClass(env, "java/lang/String");
|
||||
jstring empty = (*env)->NewStringUTF( env, "" );
|
||||
jobjectArray jarray = (*env)->NewObjectArray( env, siz, clas, empty );
|
||||
(*env)->DeleteLocalRef( env, clas );
|
||||
(*env)->DeleteLocalRef( env, empty );
|
||||
deleteLocalRefs( env, clas, empty, DELETE_NO_REF );
|
||||
|
||||
int ii;
|
||||
for ( ii = 0; !!vals && ii < siz; ++ii ) {
|
||||
jstring jstr = (*env)->NewStringUTF( env, vals[ii] );
|
||||
(*env)->SetObjectArrayElement( env, jarray, ii, jstr );
|
||||
(*env)->DeleteLocalRef( env, jstr );
|
||||
deleteLocalRef( env, jstr );
|
||||
}
|
||||
|
||||
return jarray;
|
||||
|
@ -311,7 +310,7 @@ getMethodID( JNIEnv* env, jobject obj, const char* proc, const char* sig )
|
|||
XP_ASSERT( !!cls );
|
||||
jmethodID mid = (*env)->GetMethodID( env, cls, proc, sig );
|
||||
XP_ASSERT( !!mid );
|
||||
(*env)->DeleteLocalRef( env, cls );
|
||||
deleteLocalRef( env, cls );
|
||||
return mid;
|
||||
}
|
||||
|
||||
|
@ -400,8 +399,7 @@ jenumFieldToInt( JNIEnv* env, jobject j_gi, const char* field,
|
|||
XP_ASSERT( !!jenum );
|
||||
jint result = jEnumToInt( env, jenum );
|
||||
|
||||
(*env)->DeleteLocalRef( env, clazz );
|
||||
(*env)->DeleteLocalRef( env, jenum );
|
||||
deleteLocalRefs( env, clazz, jenum, DELETE_NO_REF );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -415,7 +413,7 @@ intToJenumField( JNIEnv* env, jobject jobj, int val, const char* field,
|
|||
snprintf( buf, sizeof(buf), "L%s;", fieldSig );
|
||||
jfieldID fid = (*env)->GetFieldID( env, clazz, field, buf );
|
||||
XP_ASSERT( !!fid ); /* failed */
|
||||
(*env)->DeleteLocalRef( env, clazz );
|
||||
deleteLocalRef( env, clazz );
|
||||
|
||||
jobject jenum = (*env)->GetObjectField( env, jobj, fid );
|
||||
if ( !jenum ) { /* won't exist in new object */
|
||||
|
@ -426,13 +424,13 @@ intToJenumField( JNIEnv* env, jobject jobj, int val, const char* field,
|
|||
jenum = (*env)->NewObject( env, clazz, mid );
|
||||
XP_ASSERT( !!jenum );
|
||||
(*env)->SetObjectField( env, jobj, fid, jenum );
|
||||
(*env)->DeleteLocalRef( env, clazz );
|
||||
deleteLocalRef( env, clazz );
|
||||
}
|
||||
|
||||
jobject jval = intToJEnum( env, val, fieldSig );
|
||||
XP_ASSERT( !!jval );
|
||||
(*env)->SetObjectField( env, jobj, fid, jval );
|
||||
(*env)->DeleteLocalRef( env, jval );
|
||||
deleteLocalRef( env, jval );
|
||||
} /* intToJenumField */
|
||||
|
||||
/* Cons up a new enum instance and set its value */
|
||||
|
@ -455,8 +453,7 @@ intToJEnum( JNIEnv* env, int val, const char* enumSig )
|
|||
jenum = (*env)->GetObjectArrayElement( env, jvalues, val );
|
||||
XP_ASSERT( !!jenum );
|
||||
|
||||
(*env)->DeleteLocalRef( env, jvalues );
|
||||
(*env)->DeleteLocalRef( env, clazz );
|
||||
deleteLocalRefs( env, jvalues, clazz, DELETE_NO_REF );
|
||||
return jenum;
|
||||
} /* intToJEnum */
|
||||
|
||||
|
@ -476,6 +473,28 @@ and_empty_stream( MPFORMAL AndGlobals* globals )
|
|||
return stream;
|
||||
}
|
||||
|
||||
void deleteLocalRef( JNIEnv* env, jobject jobj )
|
||||
{
|
||||
if ( NULL != jobj ) {
|
||||
(*env)->DeleteLocalRef( env, jobj );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
deleteLocalRefs( JNIEnv* env, jobject jobj, ... )
|
||||
{
|
||||
va_list ap;
|
||||
va_start( ap, jobj );
|
||||
for ( ; ; ) {
|
||||
jobject jnext = va_arg( ap, jobject );
|
||||
if ( DELETE_NO_REF == jnext ) {
|
||||
break;
|
||||
}
|
||||
deleteLocalRef( env, jnext );
|
||||
}
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
android_debugf( const char* format, ... )
|
||||
|
|
|
@ -70,4 +70,8 @@ void intToJenumField( JNIEnv* env, jobject jobj, int val, const char* field,
|
|||
const char* fieldSig );
|
||||
jobject intToJEnum( JNIEnv* env, int val, const char* enumSig );
|
||||
jint jEnumToInt( JNIEnv* env, jobject jenum );
|
||||
|
||||
void deleteLocalRef( JNIEnv* env, jobject jobj );
|
||||
void deleteLocalRefs( JNIEnv* env, jobject jobj, ... );
|
||||
# define DELETE_NO_REF ((jobject)-1) /* terminates above varargs list */
|
||||
#endif
|
||||
|
|
|
@ -59,10 +59,8 @@ makeJRect( AndDraw* draw, int indx, const XP_Rect* rect )
|
|||
robj = (*env)->NewObject( env, rclass, initId, rect->left, rect->top,
|
||||
right, bottom );
|
||||
|
||||
(*env)->DeleteLocalRef( env, rclass );
|
||||
|
||||
draw->jCache[indx] = (*env)->NewGlobalRef( env, robj );
|
||||
(*env)->DeleteLocalRef( env, robj );
|
||||
deleteLocalRefs( env, robj, rclass, DELETE_NO_REF );
|
||||
robj = draw->jCache[indx];
|
||||
} else {
|
||||
setInt( env, robj, "left", rect->left );
|
||||
|
@ -94,7 +92,6 @@ makeJRects( AndDraw* draw, int indx, XP_U16 nPlayers, const XP_Rect rects[] )
|
|||
jclass rclass = (*env)->FindClass( env, "android/graphics/Rect");
|
||||
jrects = (*env)->NewObjectArray( env, nPlayers, rclass, NULL );
|
||||
draw->jCache[indx] = (*env)->NewGlobalRef( env, jrects );
|
||||
(*env)->DeleteLocalRef( env, jrects );
|
||||
jrects = draw->jCache[indx];
|
||||
|
||||
jmethodID initId = (*env)->GetMethodID( env, rclass, "<init>",
|
||||
|
@ -103,10 +100,10 @@ makeJRects( AndDraw* draw, int indx, XP_U16 nPlayers, const XP_Rect rects[] )
|
|||
for ( ii = 0; ii < nPlayers; ++ii ) {
|
||||
jobject jrect = (*env)->NewObject( env, rclass, initId );
|
||||
(*env)->SetObjectArrayElement( env, jrects, ii, jrect );
|
||||
(*env)->DeleteLocalRef( env, jrect );
|
||||
deleteLocalRef( env, jrect );
|
||||
}
|
||||
|
||||
(*env)->DeleteLocalRef( env, rclass );
|
||||
deleteLocalRefs( env, rclass, jrects, DELETE_NO_REF );
|
||||
}
|
||||
|
||||
if ( NULL != rects ) {
|
||||
|
@ -131,17 +128,17 @@ makeDSIs( AndDraw* draw, int indx, XP_U16 nPlayers, const DrawScoreInfo dsis[] )
|
|||
jclass clas = (*env)->FindClass( env, PKG_PATH("jni/DrawScoreInfo") );
|
||||
dsiobjs = (*env)->NewObjectArray( env, nPlayers, clas, NULL );
|
||||
draw->jCache[indx] = (*env)->NewGlobalRef( env, dsiobjs );
|
||||
(*env)->DeleteLocalRef( env, dsiobjs );
|
||||
deleteLocalRef( env, dsiobjs );
|
||||
dsiobjs = draw->jCache[indx];
|
||||
|
||||
jmethodID initId = (*env)->GetMethodID( env, clas, "<init>", "()V" );
|
||||
for ( ii = 0; ii < nPlayers; ++ii ) {
|
||||
jobject dsiobj = (*env)->NewObject( env, clas, initId );
|
||||
(*env)->SetObjectArrayElement( env, dsiobjs, ii, dsiobj );
|
||||
(*env)->DeleteLocalRef( env, dsiobj );
|
||||
deleteLocalRef( env, dsiobj );
|
||||
}
|
||||
|
||||
(*env)->DeleteLocalRef( env, clas );
|
||||
deleteLocalRef( env, clas );
|
||||
}
|
||||
|
||||
for ( ii = 0; ii < nPlayers; ++ii ) {
|
||||
|
@ -173,10 +170,9 @@ makeDSI( AndDraw* draw, int indx, const DrawScoreInfo* dsi )
|
|||
jclass rclass = (*env)->FindClass( env, PKG_PATH("jni/DrawScoreInfo") );
|
||||
jmethodID initId = (*env)->GetMethodID( env, rclass, "<init>", "()V" );
|
||||
dsiobj = (*env)->NewObject( env, rclass, initId );
|
||||
(*env)->DeleteLocalRef( env, rclass );
|
||||
|
||||
draw->jCache[indx] = (*env)->NewGlobalRef( env, dsiobj );
|
||||
(*env)->DeleteLocalRef( env, dsiobj );
|
||||
deleteLocalRefs( env, rclass, dsiobj, DELETE_NO_REF );
|
||||
dsiobj = draw->jCache[indx];
|
||||
}
|
||||
|
||||
|
@ -219,7 +215,7 @@ and_draw_scoreBegin( DrawCtx* dctx, const XP_Rect* rect,
|
|||
result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
|
||||
jrect, numPlayers, jscores, remCount );
|
||||
|
||||
(*env)->DeleteLocalRef( env, jscores );
|
||||
deleteLocalRef( env, jscores );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -389,9 +385,7 @@ and_draw_drawCell( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text,
|
|||
jrect, jtext, tile, value,
|
||||
owner, bonus, hintAtts,
|
||||
flags );
|
||||
if ( !!jtext ) {
|
||||
(*env)->DeleteLocalRef( env, jtext );
|
||||
}
|
||||
deleteLocalRef( env, jtext );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -444,9 +438,7 @@ and_draw_drawTile( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text,
|
|||
(*env)->CallVoidMethod( env, draw->jdraw, mid,
|
||||
jrect, jtext, val, flags );
|
||||
|
||||
if ( !!jtext ) {
|
||||
(*env)->DeleteLocalRef( env, jtext );
|
||||
}
|
||||
deleteLocalRef( env, jtext );
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -466,9 +458,7 @@ and_draw_drawTileMidDrag( DrawCtx* dctx, const XP_Rect* rect,
|
|||
(*env)->CallVoidMethod( env, draw->jdraw, mid,
|
||||
jrect, jtext, val, owner, flags );
|
||||
|
||||
if ( !!jtext ) {
|
||||
(*env)->DeleteLocalRef( env, jtext );
|
||||
}
|
||||
deleteLocalRef( env, jtext );
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -550,7 +540,7 @@ and_draw_getMiniWText( DrawCtx* dctx, XWMiniTextType textHint )
|
|||
const char* str = (*env)->GetStringUTFChars( env, jstr, NULL );
|
||||
snprintf( draw->miniTextBuf, VSIZE(draw->miniTextBuf), "%s", str );
|
||||
(*env)->ReleaseStringUTFChars( env, jstr, str );
|
||||
(*env)->DeleteLocalRef( env, jstr );
|
||||
deleteLocalRef( env, jstr );
|
||||
return draw->miniTextBuf;
|
||||
}
|
||||
|
||||
|
@ -567,7 +557,7 @@ and_draw_measureMiniWText( DrawCtx* dctx, const XP_UCHAR* textP,
|
|||
(*env)->CallVoidMethod( env, draw->jdraw, mid,
|
||||
jstr, widthArray, heightArray );
|
||||
|
||||
(*env)->DeleteLocalRef( env, jstr );
|
||||
deleteLocalRef( env, jstr );
|
||||
*width = getIntFromArray( env, widthArray, true );
|
||||
*height = getIntFromArray( env, heightArray, true );
|
||||
}
|
||||
|
@ -585,7 +575,7 @@ and_draw_drawMiniWindow( DrawCtx* dctx, const XP_UCHAR* text,
|
|||
(*env)->CallVoidMethod( env, draw->jdraw, mid,
|
||||
jstr, jrect );
|
||||
|
||||
(*env)->DeleteLocalRef( env, jstr );
|
||||
deleteLocalRef( env, jstr );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ and_util_makeJBitmap( JNIUtilCtxt* jniutil, int nCols, int nRows,
|
|||
|
||||
bitmap = (*env)->CallObjectMethod( env, jniutil->jjniutil, mid,
|
||||
nCols, nRows, jcolors );
|
||||
(*env)->DeleteLocalRef( env, jcolors );
|
||||
deleteLocalRef( env, jcolors );
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ and_util_splitFaces( JNIUtilCtxt* jniutil, const XP_U8* bytes, jsize len,
|
|||
jbyteArray jbytes = makeByteArray( env, len, (jbyte*)bytes );
|
||||
strarray =
|
||||
(*env)->CallObjectMethod( env, jniutil->jjniutil, mid, jbytes, isUTF8 );
|
||||
(*env)->DeleteLocalRef( env, jbytes );
|
||||
deleteLocalRef( env, jbytes );
|
||||
|
||||
return strarray;
|
||||
}
|
||||
|
@ -104,9 +104,6 @@ and_util_getMD5SumFor( JNIUtilCtxt* jniutil, const XP_UCHAR* name,
|
|||
: makeByteArray( env, len, (jbyte*)bytes );
|
||||
jstring result =
|
||||
(*env)->CallObjectMethod( env, jniutil->jjniutil, mid, jname, jbytes );
|
||||
(*env)->DeleteLocalRef( env, jname );
|
||||
if ( NULL != jbytes ) {
|
||||
(*env)->DeleteLocalRef( env, jbytes );
|
||||
}
|
||||
deleteLocalRefs( env, jname, jbytes, DELETE_NO_REF );
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -129,9 +129,7 @@ and_util_userQuery( XW_UtilCtxt* uc, UtilQueryID id, XWStreamCtxt* stream )
|
|||
jstr = streamToJString( env, stream );
|
||||
}
|
||||
result = (*env)->CallBooleanMethod( env, util->jutil, mid, id, jstr );
|
||||
if ( NULL != jstr ) {
|
||||
(*env)->DeleteLocalRef( env, jstr );
|
||||
}
|
||||
deleteLocalRef( env, jstr );
|
||||
UTIL_CBK_TAIL();
|
||||
return result;
|
||||
}
|
||||
|
@ -143,7 +141,7 @@ and_util_confirmTrade( XW_UtilCtxt* uc, const XP_UCHAR** tiles, XP_U16 nTiles )
|
|||
UTIL_CBK_HEADER("confirmTrade", "([Ljava/lang/String;)Z" );
|
||||
jobjectArray jtiles = makeStringArray( env, nTiles, tiles );
|
||||
result = (*env)->CallBooleanMethod( env, util->jutil, mid, jtiles );
|
||||
(*env)->DeleteLocalRef( env, jtiles );
|
||||
deleteLocalRef( env, jtiles );
|
||||
UTIL_CBK_TAIL();
|
||||
return result;
|
||||
}
|
||||
|
@ -160,7 +158,7 @@ and_util_userPickTileBlank( XW_UtilCtxt* uc, XP_U16 playerNum,
|
|||
result = (*env)->CallIntMethod( env, util->jutil, mid,
|
||||
playerNum, jtexts );
|
||||
|
||||
(*env)->DeleteLocalRef( env, jtexts );
|
||||
deleteLocalRef( env, jtexts );
|
||||
UTIL_CBK_TAIL();
|
||||
return result;
|
||||
}
|
||||
|
@ -178,8 +176,7 @@ and_util_userPickTileTray( XW_UtilCtxt* uc, const PickInfo* pi,
|
|||
result = (*env)->CallIntMethod( env, util->jutil, mid,
|
||||
playerNum, jtexts, jcurtiles,
|
||||
pi->thisPick );
|
||||
(*env)->DeleteLocalRef( env, jtexts );
|
||||
(*env)->DeleteLocalRef( env, jcurtiles );
|
||||
deleteLocalRefs( env, jtexts, jcurtiles, DELETE_NO_REF );
|
||||
|
||||
UTIL_CBK_TAIL();
|
||||
return result;
|
||||
|
@ -195,7 +192,7 @@ and_util_askPassword( XW_UtilCtxt* uc, const XP_UCHAR* name,
|
|||
jstring jname = (*env)->NewStringUTF( env, name );
|
||||
jstring jstr = (*env)->CallObjectMethod( env, util->jutil, mid,
|
||||
jname );
|
||||
(*env)->DeleteLocalRef( env, jname );
|
||||
deleteLocalRef( env, jname );
|
||||
|
||||
if ( NULL != jstr ) { /* null means user cancelled */
|
||||
jsize jsiz = (*env)->GetStringUTFLength( env, jstr );
|
||||
|
@ -207,7 +204,7 @@ and_util_askPassword( XW_UtilCtxt* uc, const XP_UCHAR* name,
|
|||
*len = jsiz;
|
||||
result = XP_TRUE;
|
||||
}
|
||||
(*env)->DeleteLocalRef( env, jstr );
|
||||
deleteLocalRef( env, jstr );
|
||||
}
|
||||
|
||||
UTIL_CBK_TAIL();
|
||||
|
@ -253,10 +250,7 @@ and_util_informMove( XW_UtilCtxt* uc, XWStreamCtxt* expl, XWStreamCtxt* words )
|
|||
jstring jexpl = streamToJString( env, expl );
|
||||
jstring jwords = !!words ? streamToJString( env, words ) : NULL;
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, jexpl, jwords );
|
||||
(*env)->DeleteLocalRef( env, jexpl );
|
||||
if ( !!jwords ) {
|
||||
(*env)->DeleteLocalRef( env, jwords );
|
||||
}
|
||||
deleteLocalRefs( env, jexpl, jwords, DELETE_NO_REF );
|
||||
UTIL_CBK_TAIL();
|
||||
}
|
||||
|
||||
|
@ -391,7 +385,7 @@ and_util_getUserString( XW_UtilCtxt* uc, XP_U16 stringCode )
|
|||
XP_MEMCPY( buf, jchars, len );
|
||||
buf[len] = '\0';
|
||||
(*env)->ReleaseStringUTFChars( env, jresult, jchars );
|
||||
(*env)->DeleteLocalRef( env, jresult );
|
||||
deleteLocalRef( env, jresult );
|
||||
util->userStrings[index] = buf;
|
||||
}
|
||||
|
||||
|
@ -413,7 +407,7 @@ and_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi,
|
|||
(const XP_UCHAR**)bwi->words );
|
||||
result = (*env)->CallBooleanMethod( env, util->jutil, mid,
|
||||
jwords, turn, turnLost );
|
||||
(*env)->DeleteLocalRef( env, jwords );
|
||||
deleteLocalRef( env, jwords );
|
||||
}
|
||||
UTIL_CBK_TAIL();
|
||||
return result;
|
||||
|
@ -425,7 +419,7 @@ and_util_showChat( XW_UtilCtxt* uc, const XP_UCHAR const* msg )
|
|||
UTIL_CBK_HEADER("showChat", "(Ljava/lang/String;)V" );
|
||||
jstring jmsg = (*env)->NewStringUTF( env, msg );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, jmsg );
|
||||
(*env)->DeleteLocalRef( env, jmsg );
|
||||
deleteLocalRef( env, jmsg );
|
||||
UTIL_CBK_TAIL();
|
||||
}
|
||||
|
||||
|
@ -467,8 +461,7 @@ and_util_phoneNumbersSame( XW_UtilCtxt* uc, const XP_UCHAR* p1,
|
|||
jstring js1 = (*env)->NewStringUTF( env, p1 );
|
||||
jstring js2 = (*env)->NewStringUTF( env, p2 );
|
||||
same = (*env)->CallBooleanMethod( env, util->jutil, mid, js1, js2 );
|
||||
(*env)->DeleteLocalRef( env, js1 );
|
||||
(*env)->DeleteLocalRef( env, js2 );
|
||||
deleteLocalRefs( env, js1, js2, DELETE_NO_REF );
|
||||
UTIL_CBK_TAIL();
|
||||
}
|
||||
return same;
|
||||
|
@ -483,7 +476,7 @@ and_util_cellSquareHeld( XW_UtilCtxt* uc, XWStreamCtxt* words )
|
|||
UTIL_CBK_HEADER( "cellSquareHeld", "(Ljava/lang/String;)V" );
|
||||
jstring jwords = streamToJString( env, words );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, jwords );
|
||||
(*env)->DeleteLocalRef( env, jwords );
|
||||
deleteLocalRef( env, jwords );
|
||||
UTIL_CBK_TAIL();
|
||||
}
|
||||
}
|
||||
|
@ -500,7 +493,7 @@ and_util_informMissing(XW_UtilCtxt* uc, XP_Bool isServer,
|
|||
jobject jtyp = intToJEnum( env, connType,
|
||||
PKG_PATH("jni/CommsAddrRec$CommsConnType") );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, isServer, jtyp, nMissing );
|
||||
(*env)->DeleteLocalRef( env, jtyp );
|
||||
deleteLocalRef( env, jtyp );
|
||||
UTIL_CBK_TAIL();
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ makeJAddr( JNIEnv* env, const CommsAddrRec* addr )
|
|||
|
||||
setJAddrRec( env, jaddr, addr );
|
||||
|
||||
(*env)->DeleteLocalRef( env, clazz );
|
||||
deleteLocalRef( env, clazz );
|
||||
}
|
||||
return jaddr;
|
||||
}
|
||||
|
@ -82,11 +82,7 @@ and_xport_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr,
|
|||
|
||||
result = (*env)->CallIntMethod( env, aprocs->jxport, mid,
|
||||
jbytes, jaddr, gameID );
|
||||
|
||||
if ( NULL != jaddr ) {
|
||||
(*env)->DeleteLocalRef( env, jaddr );
|
||||
}
|
||||
(*env)->DeleteLocalRef( env, jbytes );
|
||||
deleteLocalRefs( env, jaddr, jbytes, DELETE_NO_REF );
|
||||
}
|
||||
LOG_RETURNF( "%d", result );
|
||||
return result;
|
||||
|
@ -105,7 +101,7 @@ and_xport_relayStatus( void* closure, CommsRelayState newState )
|
|||
jobject jenum = intToJEnum( env, newState,
|
||||
PKG_PATH("jni/TransportProcs$CommsRelayState") );
|
||||
(*env)->CallVoidMethod( env, aprocs->jxport, mid, jenum );
|
||||
(*env)->DeleteLocalRef( env, jenum );
|
||||
deleteLocalRef( env, jenum );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +118,7 @@ and_xport_relayConnd( void* closure, XP_UCHAR* const room, XP_Bool reconnect,
|
|||
jstring str = (*env)->NewStringUTF( env, room );
|
||||
(*env)->CallVoidMethod( env, aprocs->jxport, mid,
|
||||
str, devOrder, allHere, nMissing );
|
||||
(*env)->DeleteLocalRef( env, str );
|
||||
deleteLocalRef( env, str );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,8 +138,7 @@ and_xport_sendNoConn( const XP_U8* buf, XP_U16 len,
|
|||
jstring str = (*env)->NewStringUTF( env, relayID );
|
||||
result = (*env)->CallBooleanMethod( env, aprocs->jxport, mid,
|
||||
jbytes, str );
|
||||
(*env)->DeleteLocalRef( env, jbytes );
|
||||
(*env)->DeleteLocalRef( env, str );
|
||||
deleteLocalRefs( env, jbytes, str, DELETE_NO_REF );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -163,7 +158,7 @@ and_xport_relayError( void* closure, XWREASON relayErr )
|
|||
PKG_PATH("jni/TransportProcs$XWRELAY_ERROR") );
|
||||
(*env)->CallVoidMethod( env, aprocs->jxport, mid, jenum );
|
||||
|
||||
(*env)->DeleteLocalRef( env, jenum );
|
||||
deleteLocalRef( env, jenum );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,9 +100,9 @@ makeGI( MPFORMAL JNIEnv* env, jobject j_gi )
|
|||
|
||||
lp->secondsUsed = 0;
|
||||
|
||||
(*env)->DeleteLocalRef( env, jlp );
|
||||
deleteLocalRef( env, jlp );
|
||||
}
|
||||
(*env)->DeleteLocalRef( env, jplayers );
|
||||
deleteLocalRef( env, jplayers );
|
||||
} else {
|
||||
XP_ASSERT(0);
|
||||
}
|
||||
|
@ -147,9 +147,9 @@ setJGI( JNIEnv* env, jobject jgi, const CurGameInfo* gi )
|
|||
setString( env, jlp, "dictName", lp->dictName );
|
||||
setInt( env, jlp, "secondsUsed", lp->secondsUsed );
|
||||
|
||||
(*env)->DeleteLocalRef( env, jlp );
|
||||
deleteLocalRef( env, jlp );
|
||||
}
|
||||
(*env)->DeleteLocalRef( env, jplayers );
|
||||
deleteLocalRef( env, jplayers );
|
||||
} else {
|
||||
XP_ASSERT(0);
|
||||
}
|
||||
|
@ -1052,9 +1052,9 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getAddrs
|
|||
jobject jaddr = (*env)->NewObject( env, clas, initId );
|
||||
setJAddrRec( env, jaddr, &addrs[ii] );
|
||||
(*env)->SetObjectArrayElement( env, result, ii, jaddr );
|
||||
(*env)->DeleteLocalRef( env, jaddr );
|
||||
deleteLocalRef( env, jaddr );
|
||||
}
|
||||
(*env)->DeleteLocalRef( env, clas );
|
||||
deleteLocalRef( env, clas );
|
||||
|
||||
XWJNI_END();
|
||||
return result;
|
||||
|
@ -1162,7 +1162,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
|
|||
jobjectArray jaddrs = makeStringArray( env, count, addrps );
|
||||
setObject( env, jsummary, "remoteDevs", "[Ljava/lang/String;",
|
||||
jaddrs );
|
||||
(*env)->DeleteLocalRef( env, jaddrs );
|
||||
deleteLocalRef( env, jaddrs );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -1183,7 +1183,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
|
|||
}
|
||||
jintArray jarr = makeIntArray( env, nPlayers, jvals );
|
||||
setObject( env, jsummary, "scores", "[I", jarr );
|
||||
(*env)->DeleteLocalRef( env, jarr );
|
||||
deleteLocalRef( env, jarr );
|
||||
|
||||
XWJNI_END();
|
||||
}
|
||||
|
@ -1539,7 +1539,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getPrefixes
|
|||
depth, buf, VSIZE(buf) );
|
||||
jstring jstr = (*env)->NewStringUTF( env, buf );
|
||||
(*env)->SetObjectArrayElement( env, result, ii, jstr );
|
||||
(*env)->DeleteLocalRef( env, jstr );
|
||||
deleteLocalRef( env, jstr );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Add table
Reference in a new issue