diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java index d798d4b8e..1bc06e9b8 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java @@ -517,11 +517,10 @@ public class XWPrefs { if ( -1 == flags ) { result = new CommsConnTypeSet(); if ( getRelayEnabled( context ) ) { - if ( BuildConfig.NO_NEW_RELAY ) { - result.add( CommsConnType.COMMS_CONN_MQTT ); - } else { - result.add( CommsConnType.COMMS_CONN_RELAY ); - } + CommsConnType typ = BuildConfig.NO_NEW_RELAY + ? CommsConnType.COMMS_CONN_MQTT + : CommsConnType.COMMS_CONN_RELAY; + result.add( typ ); } if ( BTUtils.BTEnabled() ) { result.add( CommsConnType.COMMS_CONN_BT ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DUtilCtxt.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DUtilCtxt.java index e05292e8d..912b23daa 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DUtilCtxt.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DUtilCtxt.java @@ -339,14 +339,14 @@ public class DUtilCtxt { public void getDictPath( int lang, String name, String[] path, byte[][] bytes ) { - Log.d( TAG, "getDictPath(%d, %s)", lang, name ); + // Log.d( TAG, "getDictPath(%d, %s)", lang, name ); String[] names = { name }; DictUtils.DictPairs pairs = DictUtils.openDicts( m_context, names ); - Log.d( TAG, "openDicts() => %s", pairs ); + // Log.d( TAG, "openDicts() => %s", pairs ); path[0] = pairs.m_paths[0]; bytes[0] = pairs.m_bytes[0]; - Log.d( TAG, "getDictPath(%s): have path: %s; bytes: %s", name, path[0], bytes[0] ); - Assert.assertTrue( path[0] != null || bytes[0] != null ); + // Log.d( TAG, "getDictPath(%s): have path: %s; bytes: %s", name, path[0], bytes[0] ); + Assert.assertTrueNR( path[0] != null || bytes[0] != null ); } public void onDupTimerChanged( int gameID, int oldVal, int newVal ) diff --git a/xwords4/android/jni/utilwrapper.c b/xwords4/android/jni/utilwrapper.c index 11fd07e21..d53ec3660 100644 --- a/xwords4/android/jni/utilwrapper.c +++ b/xwords4/android/jni/utilwrapper.c @@ -833,6 +833,8 @@ and_util_getDevUtilCtxt( XW_UtilCtxt* uc, XWEnv xwe ) static XP_UCHAR* and_dutil_md5sum( XW_DUtilCtxt* duc, XWEnv xwe, const XP_U8* ptr, XP_U32 len ) { + /* will be signed in the java world, and negative is bad! */ + XP_ASSERT( (0x80000000 & len) == 0 ); AndDUtil* dutil = (AndDUtil*)duc; JNIEnv* env = xwe; struct JNIUtilCtxt* jniutil = dutil->jniutil; diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index 1d12e9509..aca0c5158 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -1383,25 +1383,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeNewGame game_makeNewGame( MPPARM(mpool) env, &state->game, gi, globals->util, dctx, &cp, globals->xportProcs ); - - /* DictionaryCtxt* dict; */ - /* PlayerDicts dicts; */ - -/* makeDicts( MPPARM(state->globalJNI->mpool) env, */ -/* TI_IF(&state->globalJNI->ti) */ -/* state->globalJNI->dictMgr, */ -/* globals->jniutil, &dict, &dicts, j_names, j_dicts, */ -/* j_paths, j_lang ); */ -/* #ifdef STUBBED_DICT */ -/* if ( !dict ) { */ -/* XP_LOGFF( "falling back to stubbed dict" ); */ -/* dict = make_stubbed_dict( MPPARM_NOCOMMA(mpool) ); */ -/* } */ -/* #endif */ -/* model_setDictionary( state->game.model, env, dict ); */ -/* dict_unref( dict, env ); /\* game owns it now *\/ */ - /* model_setPlayerDicts( state->game.model, env, &dicts ); */ - /* dict_unref_all( &dicts, env ); */ XWJNI_END(); } /* makeNewGame */ @@ -1439,8 +1420,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeFromStream jobject jutil, jobject jdraw, jobject jcp, jobject jprocs ) { jboolean result; - /* DictionaryCtxt* dict; */ - /* PlayerDicts dicts; */ XWJNI_START_GLOBALS(); globals->gi = (CurGameInfo*)XP_CALLOC( mpool, sizeof(*globals->gi) ); @@ -1448,11 +1427,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeFromStream TI_IF(&state->globalJNI->ti) jutil, globals->gi, globals); globals->jniutil = state->globalJNI->jniutil; - /* makeDicts( MPPARM(state->globalJNI->mpool) env, */ - /* TI_IF(&state->globalJNI->ti) */ - /* state->globalJNI->dictMgr, */ - /* globals->jniutil, &dict, &dicts, jdictNames, jdicts, jpaths, */ - /* jlang ); */ if ( !!jdraw ) { globals->dctx = makeDraw( MPPARM(mpool) env, TI_IF(&state->globalJNI->ti) @@ -1471,12 +1445,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeFromStream globals->gi, globals->util, globals->dctx, &cp, globals->xportProcs ); stream_destroy( stream, env ); - /* dict_unref( dict, env ); /\* game owns it now *\/ */ - /* dict_unref_all( &dicts, env ); */ - /* If game_makeFromStream() fails, the platform-side caller still needs to - call game_dispose. That requirement's better than having cleanup code - in two places. */ if ( result ) { XP_ASSERT( 0 != globals->gi->gameID ); if ( !!jgi ) { diff --git a/xwords4/common/dictnry.c b/xwords4/common/dictnry.c index 1dd93f751..e16f98bf0 100644 --- a/xwords4/common/dictnry.c +++ b/xwords4/common/dictnry.c @@ -76,8 +76,8 @@ p_dict_unref( const DictionaryCtxt* dict, XWEnv xwe --_dict->refCount; XP_ASSERT( 0 <= _dict->refCount ); #ifdef DEBUG_REF - XP_LOGF( "(dict=%p): refCount now %d (from line %d of %s() in %s)", - dict, dict->refCount, line, func, file ); + XP_LOGFF( "(dict=%p): refCount now %d (from line %d of %s() in %s)", + dict, dict->refCount, line, func, file ); #endif pthread_mutex_unlock( &_dict->mutex ); if ( 0 == _dict->refCount ) { diff --git a/xwords4/common/mempool.c b/xwords4/common/mempool.c index ece3a7b45..a4886747a 100644 --- a/xwords4/common/mempool.c +++ b/xwords4/common/mempool.c @@ -72,8 +72,7 @@ struct MemPoolCtx { XP_U16 nFree; XP_U16 nUsed; XP_U16 nAllocs; - XP_U32 maxBytes; - XP_U32 curBytes; + MPStatsBuf stats; XP_UCHAR tag[64]; }; @@ -214,9 +213,9 @@ mpool_alloc( MemPoolCtx* mpool, XP_U32 size, const char* file, entry->index = ++mpool->nAllocs; ++mpool->nUsed; - mpool->curBytes += size; - if ( mpool->curBytes > mpool->maxBytes ) { - mpool->maxBytes = mpool->curBytes; + mpool->stats.curBytes += size; + if ( mpool->stats.curBytes > mpool->stats.maxBytes ) { + mpool->stats.maxBytes = mpool->stats.curBytes; } #ifdef MPOOL_DEBUG @@ -280,9 +279,9 @@ mpool_realloc( MemPoolCtx* mpool, void* ptr, XP_U32 newsize, const char* file, entry->fileName = file; entry->func = func; entry->lineNo = lineNo; - mpool->curBytes += newsize - entry->size; - if ( mpool->curBytes > mpool->maxBytes ) { - mpool->maxBytes = mpool->curBytes; + mpool->stats.curBytes += newsize - entry->size; + if ( mpool->stats.curBytes > mpool->stats.maxBytes ) { + mpool->stats.maxBytes = mpool->stats.curBytes; } entry->size = newsize; } @@ -319,7 +318,7 @@ mpool_free( MemPoolCtx* mpool, void* ptr, const char* file, } else { mpool->usedList = entry->next; } - mpool->curBytes -= entry->size; + mpool->stats.curBytes -= entry->size; XP_MEMSET( entry->ptr, 0x00, entry->size ); XP_PLATFREE( entry->ptr ); @@ -354,15 +353,9 @@ mpool_freep( MemPoolCtx* mpool, void** ptr, const char* file, XP_Bool mpool_getStats( const MemPoolCtx* mpool, MPStatsBuf* io ) { - XP_Bool changed = XP_FALSE; - - if ( io->curBytes != mpool->curBytes ) { - changed = XP_TRUE; - io->curBytes = mpool->curBytes; - } - if ( io->maxBytes != mpool->maxBytes ) { - changed = XP_TRUE; - io->maxBytes = mpool->maxBytes; + XP_Bool changed = 0 != XP_MEMCMP( &mpool->stats, io, sizeof(mpool->stats) ); + if ( changed ) { + *io = mpool->stats; } return changed; }