diff --git a/xwords4/common/board.c b/xwords4/common/board.c index 9a5baceec..117b4a7e4 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -159,10 +159,10 @@ static void clearCurHintRect( BoardCtxt* board ); * ****************************************************************************/ BoardCtxt* -board_make( MPFORMAL XWEnv xwe, ModelCtxt* model, ServerCtxt* server, +board_make( XWEnv xwe, ModelCtxt* model, ServerCtxt* server, DrawCtx* draw, XW_UtilCtxt* util ) { - BoardCtxt* result = (BoardCtxt*)XP_MALLOC( mpool, sizeof( *result ) ); + BoardCtxt* result = (BoardCtxt*)XP_MALLOC( util->mpool, sizeof( *result ) ); XP_ASSERT( !!server ); XP_ASSERT( !!util ); XP_ASSERT( !!model ); @@ -172,7 +172,7 @@ board_make( MPFORMAL XWEnv xwe, ModelCtxt* model, ServerCtxt* server, XP_MEMSET( result, 0, sizeof( *result ) ); result->selInfo = result->pti; /* equates to selPlayer == 0 */ - MPASSIGN(result->mpool, mpool); + MPASSIGN(result->mpool, util->mpool); result->model = model; result->server = server; @@ -214,7 +214,7 @@ board_destroy( BoardCtxt* board, XWEnv xwe, XP_Bool ownsUtil ) } /* board_destroy */ BoardCtxt* -board_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, ModelCtxt* model, +board_makeFromStream( XWEnv xwe, XWStreamCtxt* stream, ModelCtxt* model, ServerCtxt* server, DrawCtx* draw, XW_UtilCtxt* util, XP_U16 nPlayers ) { @@ -227,7 +227,7 @@ board_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, ModelCtxt* model nColsNBits = NUMCOLS_NBITS_4; #endif - board = board_make( MPPARM(mpool) xwe, model, server, draw, util ); + board = board_make( xwe, model, server, draw, util ); board_setCallbacks( board, xwe ); if ( version >= STREAM_VERS_4YOFFSET) { @@ -415,8 +415,7 @@ void board_drawSnapshot( const BoardCtxt* curBoard, XWEnv xwe, DrawCtx* dctx, XP_U16 width, XP_U16 height ) { - BoardCtxt* newBoard = board_make( MPPARM(curBoard->mpool) xwe, - curBoard->model, + BoardCtxt* newBoard = board_make( xwe, curBoard->model, curBoard->server, dctx, curBoard->util ); board_setDraw( newBoard, xwe, dctx ); /* so draw_dictChanged() will get called */ XP_U16 fontWidth = width / curBoard->gi->boardSize; diff --git a/xwords4/common/board.h b/xwords4/common/board.h index c1f87e780..0f5061bd5 100644 --- a/xwords4/common/board.h +++ b/xwords4/common/board.h @@ -56,9 +56,9 @@ typedef enum { /* typedef struct BoardCtxt BoardCtxt; */ -BoardCtxt* board_make( MPFORMAL XWEnv xwe, ModelCtxt* model, ServerCtxt* server, +BoardCtxt* board_make( XWEnv xwe, ModelCtxt* model, ServerCtxt* server, DrawCtx* draw, XW_UtilCtxt* util ); -BoardCtxt* board_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, +BoardCtxt* board_makeFromStream( XWEnv xwe, XWStreamCtxt* stream, ModelCtxt* model, ServerCtxt* server, DrawCtx* draw, XW_UtilCtxt* util, XP_U16 nPlayers ); diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 6b302a7fb..4bce507aa 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -406,7 +406,7 @@ init_relay( CommsCtxt* comms, XWEnv xwe, XP_U16 nPlayersHere, XP_U16 nPlayersTot #endif CommsCtxt* -comms_make( MPFORMAL XWEnv xwe, XW_UtilCtxt* util, XP_Bool isServer, +comms_make( XWEnv xwe, XW_UtilCtxt* util, XP_Bool isServer, const CommsAddrRec* selfAddr, const CommsAddrRec* hostAddr, const TransportProcs* procs, #ifdef XWFEATURE_RELAY @@ -415,15 +415,15 @@ comms_make( MPFORMAL XWEnv xwe, XW_UtilCtxt* util, XP_Bool isServer, #endif XP_U16 forceChannel ) { - CommsCtxt* comms = (CommsCtxt*)XP_CALLOC( mpool, sizeof(*comms) ); + CommsCtxt* comms = (CommsCtxt*)XP_CALLOC( util->mpool, sizeof(*comms) ); MUTEX_INIT_CHECKED( &comms->mutex, XP_TRUE, 3 ); comms->util = util; comms->dutil = util_getDevUtilCtxt( util, xwe ); #ifdef DEBUG - comms->tag = mpool_getTag(mpool); + comms->tag = mpool_getTag(util->mpool); COMMS_LOGFF( TAGFMT(isServer=%d; forceChannel=%d), TAGPRMS, isServer, forceChannel ); #endif - MPASSIGN(comms->mpool, mpool); + MPASSIGN(comms->mpool, util->mpool); XP_ASSERT( 0 == (forceChannel & ~CHANNEL_MASK) ); comms->isServer = isServer; @@ -744,7 +744,7 @@ writeChannelNo( XWStreamCtxt* stream, XP_PlayerAddr channelNo ) } CommsCtxt* -comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, +comms_makeFromStream( XWEnv xwe, XWStreamCtxt* stream, XW_UtilCtxt* util, XP_Bool isServer, const TransportProcs* procs, #ifdef XWFEATURE_RELAY @@ -778,7 +778,7 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, nPlayersHere = 0; nPlayersTotal = 0; } - CommsCtxt* comms = comms_make( MPPARM(mpool) xwe, util, isServer, + CommsCtxt* comms = comms_make( xwe, util, isServer, NULL, NULL, procs, #ifdef XWFEATURE_RELAY nPlayersHere, nPlayersTotal, rcp, rcClosure, @@ -821,7 +821,7 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, COMMS_LOGFFV( "nAddrRecs: %d", nAddrRecs ); AddressRecord** prevsAddrNext = &comms->recs; for ( int ii = 0; ii < nAddrRecs; ++ii ) { - AddressRecord* rec = (AddressRecord*)XP_CALLOC( mpool, sizeof(*rec)); + AddressRecord* rec = (AddressRecord*)XP_CALLOC( util->mpool, sizeof(*rec)); addrFromStream( &rec->addr, stream ); logAddrComms( comms, &rec->addr, __func__ ); @@ -853,7 +853,7 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, } for ( int ii = 0; ii < queueLen; ++ii ) { - MsgQueueElem* msg = (MsgQueueElem*)XP_CALLOC( mpool, sizeof(*msg) ); + MsgQueueElem* msg = (MsgQueueElem*)XP_CALLOC( util->mpool, sizeof(*msg) ); msg->channelNo = readChannelNo( stream ); if ( version >= STREAM_VERS_SMALLCOMMS ) { @@ -881,7 +881,7 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, stream_getFromStream( nliStream, stream, nliLen ); NetLaunchInfo nli; if ( nli_makeFromStream( &nli, nliStream ) ) { - msg->smp.buf = (XP_U8*)XP_MALLOC( mpool, sizeof(nli) ); + msg->smp.buf = (XP_U8*)XP_MALLOC( util->mpool, sizeof(nli) ); XP_MEMCPY( (void*)msg->smp.buf, &nli, sizeof(nli) ); len = sizeof(nli); /* needed for checksum calc */ } else { @@ -889,7 +889,7 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, } stream_destroy( nliStream ); } else { - msg->smp.buf = (XP_U8*)XP_MALLOC( mpool, len ); + msg->smp.buf = (XP_U8*)XP_MALLOC( util->mpool, len ); stream_getBytes( stream, (XP_U8*)msg->smp.buf, len ); } dutil_md5sum( comms->dutil, xwe, msg->smp.buf, len, &msg->sb ); diff --git a/xwords4/common/comms.h b/xwords4/common/comms.h index d721cf617..b7d9b1498 100644 --- a/xwords4/common/comms.h +++ b/xwords4/common/comms.h @@ -143,7 +143,7 @@ typedef struct _TransportProcs { void* closure; } TransportProcs; -CommsCtxt* comms_make( MPFORMAL XWEnv xwe, XW_UtilCtxt* util, +CommsCtxt* comms_make( XWEnv xwe, XW_UtilCtxt* util, XP_Bool isServer, const CommsAddrRec* selfAddr, const CommsAddrRec* hostAddr, @@ -180,7 +180,7 @@ XP_Bool comms_getRelayID( const CommsCtxt* comms, XP_UCHAR* buf, XP_U16* len ); void comms_dropHostAddr( CommsCtxt* comms, CommsConnType typ ); XP_Bool comms_getIsHost( const CommsCtxt* comms ); -CommsCtxt* comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, +CommsCtxt* comms_makeFromStream( XWEnv xwe, XWStreamCtxt* stream, XW_UtilCtxt* util, XP_Bool isServer, const TransportProcs* procs, #ifdef XWFEATURE_RELAY diff --git a/xwords4/common/engine.c b/xwords4/common/engine.c index c46f71fe6..89f77af47 100644 --- a/xwords4/common/engine.c +++ b/xwords4/common/engine.c @@ -178,12 +178,12 @@ engine_getScoreCache( EngineCtxt* engine, XP_U16 row ) * turn it into a separate code module later. ****************************************************************************/ EngineCtxt* -engine_make( MPFORMAL XW_UtilCtxt* util ) +engine_make( XW_UtilCtxt* util ) { - EngineCtxt* result = (EngineCtxt*)XP_MALLOC( mpool, sizeof(*result) ); + EngineCtxt* result = (EngineCtxt*)XP_MALLOC( util->mpool, sizeof(*result) ); XP_MEMSET( result, 0, sizeof(*result) ); - MPASSIGN(result->mpool, mpool); + MPASSIGN(result->mpool, util->mpool); result->util = util; @@ -200,10 +200,10 @@ engine_writeToStream( EngineCtxt* XP_UNUSED(ctxt), } /* engine_writeToStream */ EngineCtxt* -engine_makeFromStream( MPFORMAL XWStreamCtxt* XP_UNUSED(stream), +engine_makeFromStream( XWStreamCtxt* XP_UNUSED(stream), XW_UtilCtxt* util ) { - EngineCtxt* engine = engine_make( MPPARM(mpool) util ); + EngineCtxt* engine = engine_make( util ); /* All the engine's data seems to be used only in the process of finding a move. So if we're willing to have the set of moves found lost across diff --git a/xwords4/common/engine.h b/xwords4/common/engine.h index 1ac1e5f58..1b9503de1 100644 --- a/xwords4/common/engine.h +++ b/xwords4/common/engine.h @@ -38,10 +38,10 @@ typedef struct BdHintLimits { XP_U16 engine_getScoreCache( EngineCtxt* engine, XP_U16 row ); -EngineCtxt* engine_make( MPFORMAL XW_UtilCtxt* util ); +EngineCtxt* engine_make( XW_UtilCtxt* util ); void engine_writeToStream( EngineCtxt* ctxt, XWStreamCtxt* stream ); -EngineCtxt* engine_makeFromStream( MPFORMAL XWStreamCtxt* stream, +EngineCtxt* engine_makeFromStream( XWStreamCtxt* stream, XW_UtilCtxt* util ); void engine_init( EngineCtxt* ctxt ); diff --git a/xwords4/common/game.c b/xwords4/common/game.c index c908e54fd..32e7f93c3 100644 --- a/xwords4/common/game.c +++ b/xwords4/common/game.c @@ -195,7 +195,7 @@ game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi, model_setPlayerDicts( game->model, xwe, &playerDicts ); if ( gi->serverRole != SERVER_STANDALONE ) { - game->comms = comms_make( MPPARM(mpool) xwe, util, + game->comms = comms_make( xwe, util, gi->serverRole != SERVER_ISCLIENT, selfAddr, hostAddr, procs, #ifdef XWFEATURE_RELAY @@ -209,9 +209,8 @@ game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi, } - game->server = server_make( MPPARM(mpool) xwe, game->model, - game->comms, util ); - game->board = board_make( MPPARM(mpool) xwe, game->model, game->server, + game->server = server_make( xwe, game->model, game->comms, util ); + game->board = board_make( xwe, game->model, game->server, NULL, util ); board_setCallbacks( game->board, xwe ); @@ -358,7 +357,7 @@ game_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, XP_ASSERT( hasComms == (SERVER_STANDALONE != gi->serverRole) ); if ( hasComms ) { - game->comms = comms_makeFromStream( MPPARM(mpool) xwe, stream, util, + game->comms = comms_makeFromStream( xwe, stream, util, gi->serverRole != SERVER_ISCLIENT, procs, #ifdef XWFEATURE_RELAY @@ -373,11 +372,11 @@ game_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, game->model = model_makeFromStream( MPPARM(mpool) xwe, stream, dict, &playerDicts, util ); - game->server = server_makeFromStream( MPPARM(mpool) xwe, stream, + game->server = server_makeFromStream( xwe, stream, game->model, game->comms, util, gi->nPlayers ); - game->board = board_makeFromStream( MPPARM(mpool) xwe, stream, + game->board = board_makeFromStream( xwe, stream, game->model, game->server, NULL, util, gi->nPlayers ); setListeners( game, cp ); diff --git a/xwords4/common/server.c b/xwords4/common/server.c index 3b617116b..2cdd0d5f2 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -420,14 +420,14 @@ initServer( ServerCtxt* server, XWEnv xwe ) } /* initServer */ ServerCtxt* -server_make( MPFORMAL XWEnv xwe, ModelCtxt* model, CommsCtxt* comms, XW_UtilCtxt* util ) +server_make( XWEnv xwe, ModelCtxt* model, CommsCtxt* comms, XW_UtilCtxt* util ) { - ServerCtxt* result = (ServerCtxt*)XP_MALLOC( mpool, sizeof(*result) ); + ServerCtxt* result = (ServerCtxt*)XP_MALLOC( util->mpool, sizeof(*result) ); if ( result != NULL ) { XP_MEMSET( result, 0, sizeof(*result) ); - MPASSIGN(result->mpool, mpool); + MPASSIGN(result->mpool, util->mpool); result->vol.model = model; result->vol.comms = comms; @@ -617,17 +617,17 @@ server_getPendingRegs( const ServerCtxt* server ) } ServerCtxt* -server_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, ModelCtxt* model, +server_makeFromStream( XWEnv xwe, XWStreamCtxt* stream, ModelCtxt* model, CommsCtxt* comms, XW_UtilCtxt* util, XP_U16 nPlayers ) { ServerCtxt* server; XP_U16 version = stream_getVersion( stream ); - server = server_make( MPPARM(mpool) xwe, model, comms, util ); + server = server_make( xwe, model, comms, util ); getNV( stream, &server->nv, nPlayers ); if ( stream_getBits(stream, 1) != 0 ) { - server->pool = pool_makeFromStream( MPPARM(mpool) stream ); + server->pool = pool_makeFromStream( MPPARM(util->mpool) stream ); } for ( int ii = 0; ii < nPlayers; ++ii ) { @@ -636,8 +636,7 @@ server_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, ModelCtxt* mode player->deviceIndex = stream_getU8( stream ); if ( stream_getU8( stream ) != 0 ) { - player->engine = engine_makeFromStream( MPPARM(mpool) - stream, util ); + player->engine = engine_makeFromStream( stream, util ); } } @@ -2628,8 +2627,7 @@ server_getEngineFor( ServerCtxt* server, XP_U16 playerNum ) EngineCtxt* engine = player->engine; if ( !engine && (inDuplicateMode(server) || gi->players[playerNum].isLocal) ) { - engine = engine_make( MPPARM(server->mpool) - server->vol.util ); + engine = engine_make( server->vol.util ); player->engine = engine; } @@ -2739,7 +2737,7 @@ trayAllowsMoves( ServerCtxt* server, XWEnv xwe, XP_U16 turn, EngineCtxt* tmpEngine = NULL; EngineCtxt* engine = server_getEngineFor( server, turn ); if ( !engine ) { - tmpEngine = engine = engine_make( MPPARM(server->mpool) server->vol.util ); + tmpEngine = engine = engine_make( server->vol.util ); } XP_Bool canMove; MoveInfo newMove = {}; diff --git a/xwords4/common/server.h b/xwords4/common/server.h index 61e9613eb..716c026d7 100644 --- a/xwords4/common/server.h +++ b/xwords4/common/server.h @@ -31,10 +31,10 @@ extern "C" { #endif -ServerCtxt* server_make( MPFORMAL XWEnv xwe, ModelCtxt* model, CommsCtxt* comms, +ServerCtxt* server_make( XWEnv xwe, ModelCtxt* model, CommsCtxt* comms, XW_UtilCtxt* util ); -ServerCtxt* server_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, +ServerCtxt* server_makeFromStream( XWEnv xwe, XWStreamCtxt* stream, ModelCtxt* model, CommsCtxt* comms, XW_UtilCtxt* util, XP_U16 nPlayers );