mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
one less malloc
This commit is contained in:
parent
de7be6cf44
commit
2744649e48
1 changed files with 3 additions and 3 deletions
|
@ -629,6 +629,7 @@ server_initClientConnection( ServerCtxt* server, XWStreamCtxt* stream )
|
|||
}
|
||||
stream_putBits( stream, NAME_LEN_NBITS, len );
|
||||
stream_putBytes( stream, name, len );
|
||||
XP_LOGF( "%s(): wrote local name %s", __func__, name );
|
||||
}
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
stream_putU8( stream, CUR_STREAM_VERS );
|
||||
|
@ -1246,7 +1247,6 @@ registerRemotePlayer( ServerCtxt* server, XWStreamCtxt* stream )
|
|||
{
|
||||
XP_S8 deviceIndex = -1;
|
||||
XP_PlayerAddr channelNo;
|
||||
XP_UCHAR* name;
|
||||
XP_U16 nameLen;
|
||||
LocalPlayer* lp;
|
||||
ServerPlayer* player = (ServerPlayer*)NULL;
|
||||
|
@ -1262,12 +1262,12 @@ registerRemotePlayer( ServerCtxt* server, XWStreamCtxt* stream )
|
|||
/* get data from stream */
|
||||
lp->robotIQ = 1 == stream_getBits( stream, 1 )? 1 : 0;
|
||||
nameLen = stream_getBits( stream, NAME_LEN_NBITS );
|
||||
name = (XP_UCHAR*)XP_MALLOC( server->mpool, nameLen + 1 );
|
||||
XP_UCHAR name[nameLen + 1];
|
||||
stream_getBytes( stream, name, nameLen );
|
||||
name[nameLen] = '\0';
|
||||
XP_LOGF( "%s(): read remote name: %s", __func__, name );
|
||||
|
||||
replaceStringIfDifferent( server->mpool, &lp->name, name );
|
||||
XP_FREE( server->mpool, name );
|
||||
|
||||
channelNo = stream_getAddress( stream );
|
||||
deviceIndex = getIndexForDevice( server, channelNo );
|
||||
|
|
Loading…
Reference in a new issue