mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
turn stringFromStream into macro to aid logging for leak detection. Debug builds only effected.
This commit is contained in:
parent
1ad222c409
commit
6dc75914a6
7 changed files with 28 additions and 12 deletions
|
@ -333,7 +333,7 @@ dict_loadFromStream( DictionaryCtxt* dict, XWStreamCtxt* stream )
|
|||
for ( nSpecials = i = 0; i < nFaces; ++i ) {
|
||||
XP_UCHAR face = dict_getTileChar( dict, (Tile)i );
|
||||
if ( IS_SPECIAL( face ) ) {
|
||||
XP_UCHAR* txt = stringFromStream( MPPARM(dict->mpool) stream );
|
||||
XP_UCHAR* txt = stringFromStream( dict->mpool, stream );
|
||||
XP_ASSERT( !!txt );
|
||||
localTexts[nSpecials] = txt;
|
||||
|
||||
|
|
|
@ -367,7 +367,7 @@ gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi )
|
|||
XP_UCHAR* str;
|
||||
XP_U16 strVersion = stream_getVersion( stream );
|
||||
|
||||
str = stringFromStream( MPPARM(mpool) stream );
|
||||
str = stringFromStream( mpool, stream );
|
||||
replaceStringIfDifferent( mpool, &gi->dictName, str );
|
||||
if ( !!str ) {
|
||||
XP_FREE( mpool, str );
|
||||
|
@ -395,13 +395,13 @@ gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi )
|
|||
}
|
||||
|
||||
for ( pl = gi->players, i = 0; i < gi->nPlayers; ++pl, ++i ) {
|
||||
str = stringFromStream( MPPARM(mpool) stream );
|
||||
str = stringFromStream( mpool, stream );
|
||||
replaceStringIfDifferent( mpool, &pl->name, str );
|
||||
if ( !!str ) {
|
||||
XP_FREE( mpool, str );
|
||||
}
|
||||
|
||||
str = stringFromStream( MPPARM(mpool) stream );
|
||||
str = stringFromStream( mpool, stream );
|
||||
replaceStringIfDifferent( mpool, &pl->password, str );
|
||||
if ( !!str ) {
|
||||
XP_FREE( mpool, str );
|
||||
|
|
|
@ -1152,7 +1152,7 @@ bwiFromStream( MPFORMAL XWStreamCtxt* stream, BadWordInfo* bwi )
|
|||
|
||||
bwi->nWords = nWords;
|
||||
for ( sp = bwi->words; nWords; ++sp, --nWords ) {
|
||||
*sp = stringFromStream( MPPARM(mpool) stream );
|
||||
*sp = stringFromStream( mpool, stream );
|
||||
}
|
||||
} /* bwiFromStream */
|
||||
|
||||
|
|
|
@ -98,14 +98,22 @@ signedFromStream( XWStreamCtxt* stream, XP_U16 nBits )
|
|||
#endif
|
||||
|
||||
XP_UCHAR*
|
||||
stringFromStream( MPFORMAL XWStreamCtxt* stream )
|
||||
p_stringFromStream( MPFORMAL XWStreamCtxt* stream
|
||||
#ifdef MEM_DEBUG
|
||||
, const char* file, XP_U32 lineNo
|
||||
#endif
|
||||
)
|
||||
{
|
||||
XP_UCHAR buf[0xFF];
|
||||
XP_UCHAR* str = (XP_UCHAR*)NULL;
|
||||
XP_U16 len = stringFromStreamHere( stream, buf, sizeof(buf) );
|
||||
|
||||
if ( len > 0 ) {
|
||||
str = (XP_UCHAR*)XP_MALLOC( mpool, len + 1 );
|
||||
#ifdef MEM_DEBUG
|
||||
str = mpool_alloc( mpool, len + 1, file, lineNo );
|
||||
#else
|
||||
str = (XP_UCHAR*)XP_MALLOC( mpool, len + 1 ); /* leaked */
|
||||
#endif
|
||||
XP_MEMCPY( str, buf, len + 1 );
|
||||
}
|
||||
return str;
|
||||
|
|
|
@ -37,7 +37,17 @@ void traySetFromStream( XWStreamCtxt* stream, TrayTileSet* ts );
|
|||
XP_S32 signedFromStream( XWStreamCtxt* stream, XP_U16 nBits );
|
||||
void signedToStream( XWStreamCtxt* stream, XP_U16 nBits, XP_S32 num );
|
||||
|
||||
XP_UCHAR* stringFromStream( MPFORMAL XWStreamCtxt* stream );
|
||||
XP_UCHAR* p_stringFromStream( MPFORMAL XWStreamCtxt* stream
|
||||
#ifdef MEM_DEBUG
|
||||
, const char* file, XP_U32 lineNo
|
||||
#endif
|
||||
);
|
||||
#ifdef MEM_DEBUG
|
||||
# define stringFromStream( p, in ) p_stringFromStream( (p), (in), __FILE__, __LINE__ )
|
||||
#else
|
||||
# define stringFromStream( p, in ) p_stringFromStream( in )
|
||||
#endif
|
||||
|
||||
XP_U16 stringFromStreamHere( XWStreamCtxt* stream, XP_UCHAR* buf, XP_U16 len );
|
||||
void stringToStream( XWStreamCtxt* stream, const XP_UCHAR* str );
|
||||
|
||||
|
|
|
@ -581,8 +581,7 @@ loadCurrentGame( PalmAppGlobals* globals, XP_U16 gIndex,
|
|||
|
||||
hasDict = stream_getU8( recStream );
|
||||
if ( hasDict ) {
|
||||
XP_UCHAR* name = stringFromStream( MPPARM(globals->mpool)
|
||||
recStream );
|
||||
XP_UCHAR* name = stringFromStream( globals->mpool, recStream );
|
||||
dict = palm_dictionary_make( MPPARM(globals->mpool) globals,
|
||||
name, globals->dictList );
|
||||
success = dict != NULL;
|
||||
|
|
|
@ -955,8 +955,7 @@ ceLoadSavedGame( CEAppGlobals* globals )
|
|||
#ifdef STUBBED_DICT
|
||||
XP_ASSERT(0); /* just don't do this!!!! */
|
||||
#else
|
||||
XP_UCHAR* name = stringFromStream( MPPARM(globals->mpool)
|
||||
stream );
|
||||
XP_UCHAR* name = stringFromStream( globals->mpool, stream );
|
||||
dict = ce_dictionary_make( globals, name );
|
||||
XP_FREE( globals->mpool, name );
|
||||
success = dict != NULL;
|
||||
|
|
Loading…
Reference in a new issue