mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
fix valgrind-flagged errors
This commit is contained in:
parent
fecbfdddb6
commit
3bb6f842b2
2 changed files with 19 additions and 14 deletions
|
@ -221,27 +221,28 @@ dict_splitFaces( DictionaryCtxt* dict, const XP_U8* utf8,
|
|||
XP_U16 ii;
|
||||
XP_Bool isUTF8 = dict->isUTF8;
|
||||
XP_UCHAR* next = faces;
|
||||
const gchar* bytes = (const gchar*)utf8;
|
||||
const gchar* bytesIn = (const gchar*)utf8;
|
||||
const gchar* bytesEnd = bytesIn + nBytes;
|
||||
|
||||
for ( ii = 0; ii < nFaces; ++ii ) {
|
||||
ptrs[ii] = next;
|
||||
if ( isUTF8 ) {
|
||||
for ( ; ; ) {
|
||||
gchar* cp = g_utf8_offset_to_pointer( bytes, 1 );
|
||||
size_t len = cp - bytes;
|
||||
XP_MEMCPY( next, bytes, len );
|
||||
gchar* cp = g_utf8_offset_to_pointer( bytesIn, 1 );
|
||||
size_t len = cp - bytesIn;
|
||||
XP_MEMCPY( next, bytesIn, len );
|
||||
next += len;
|
||||
bytes += len;
|
||||
if ( SYNONYM_DELIM != bytes[0] ) {
|
||||
bytesIn += len;
|
||||
if ( bytesIn >= bytesEnd || SYNONYM_DELIM != bytesIn[0] ) {
|
||||
break;
|
||||
}
|
||||
++bytes; /* skip delimiter */
|
||||
++bytesIn; /* skip delimiter */
|
||||
*next++ = '\0';
|
||||
}
|
||||
} else {
|
||||
XP_ASSERT( 0 == *bytes );
|
||||
++bytes; /* skip empty */
|
||||
*next++ = *bytes++;
|
||||
XP_ASSERT( 0 == *bytesIn );
|
||||
++bytesIn; /* skip empty */
|
||||
*next++ = *bytesIn++;
|
||||
}
|
||||
XP_ASSERT( next < faces + nFaces + nBytes );
|
||||
*next++ = '\0';
|
||||
|
|
|
@ -83,11 +83,15 @@ static int blocking_read( int fd, unsigned char* buf, const int len );
|
|||
XP_Bool
|
||||
file_exists( const char* fileName )
|
||||
{
|
||||
struct stat statBuf;
|
||||
XP_Bool exists = !!fileName;
|
||||
if ( exists ) {
|
||||
struct stat statBuf;
|
||||
|
||||
int statResult = stat( fileName, &statBuf );
|
||||
// XP_LOGF( "%s(%s)=>%d", __func__, fileName, statResult == 0 );
|
||||
return statResult == 0;
|
||||
int statResult = stat( fileName, &statBuf );
|
||||
// XP_LOGF( "%s(%s)=>%d", __func__, fileName, statResult == 0 );
|
||||
exists = statResult == 0;
|
||||
}
|
||||
return exists;
|
||||
} /* file_exists */
|
||||
|
||||
XWStreamCtxt*
|
||||
|
|
Loading…
Reference in a new issue