mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-20 22:26:54 +01:00
implement symReplaceStrIfDiff
This commit is contained in:
parent
adb26f5056
commit
576915cd3f
1 changed files with 30 additions and 0 deletions
|
@ -24,6 +24,36 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "comtypes.h"
|
||||
#include "mempool.h"
|
||||
|
||||
|
||||
void
|
||||
symReplaceStrIfDiff( MPFORMAL XP_UCHAR** loc, const TDesC16& desc )
|
||||
{
|
||||
TBuf8<256> tmp;
|
||||
tmp.Copy( desc );
|
||||
|
||||
if ( *loc ) {
|
||||
TPtrC8 forCmp;
|
||||
forCmp.Set( *loc, XP_STRLEN( *loc ) );
|
||||
|
||||
if ( tmp == forCmp ) {
|
||||
XP_LOGF( "not copying %s", *loc );
|
||||
return;
|
||||
}
|
||||
|
||||
XP_LOGF( "freeing %s", *loc );
|
||||
XP_FREE( mpool, *loc );
|
||||
}
|
||||
|
||||
TInt len = desc.Length();
|
||||
XP_UCHAR* newStr = (XP_UCHAR*)XP_MALLOC( mpool, len + 1 );
|
||||
XP_MEMCPY( newStr, (void*)tmp.Ptr(), len );
|
||||
newStr[len] = '\0';
|
||||
*loc = newStr;
|
||||
|
||||
XP_LOGF( "created new string: %s", newStr );
|
||||
} /* symReplaceStr */
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
Loading…
Reference in a new issue