palm_dictionary_make makes copy of name if needed. Helps plug memory leak.

This commit is contained in:
ehouse 2007-03-18 23:49:15 +00:00
parent 2bb3c946d9
commit 6f7db1a202
2 changed files with 5 additions and 3 deletions

View file

@ -24,6 +24,7 @@
#include "dictnryp.h" #include "dictnryp.h"
#include "dawg.h" #include "dawg.h"
#include "strutils.h"
#include "palmdict.h" #include "palmdict.h"
#include "dictlist.h" #include "dictlist.h"
#include "dictui.h" #include "dictui.h"
@ -67,7 +68,7 @@ static array_edge* palm_dict_edge_for_index_multi( const DictionaryCtxt* dict,
DictionaryCtxt* DictionaryCtxt*
palm_dictionary_make( MPFORMAL PalmAppGlobals* globals, palm_dictionary_make( MPFORMAL PalmAppGlobals* globals,
XP_UCHAR* dictName, PalmDictList* dl ) const XP_UCHAR* dictName, PalmDictList* dl )
{ {
Boolean found; Boolean found;
UInt16 cardNo; UInt16 cardNo;
@ -116,7 +117,7 @@ palm_dictionary_make( MPFORMAL PalmAppGlobals* globals,
if ( !!dictName ) { if ( !!dictName ) {
XP_ASSERT( XP_STRLEN((const char*)dictName) > 0 ); XP_ASSERT( XP_STRLEN((const char*)dictName) > 0 );
ctxt->super.name = dictName; ctxt->super.name = copyString( mpool, dictName );
ctxt->super.destructor = palm_dictionary_destroy; ctxt->super.destructor = palm_dictionary_destroy;
found = getDictWithName( dl, dictName, &dle ); found = getDictWithName( dl, dictName, &dle );

View file

@ -25,7 +25,8 @@
#include "dictui.h" #include "dictui.h"
DictionaryCtxt* palm_dictionary_make( MPFORMAL PalmAppGlobals* globals, DictionaryCtxt* palm_dictionary_make( MPFORMAL PalmAppGlobals* globals,
XP_UCHAR* dictName, PalmDictList* dl ); const XP_UCHAR* dictName, /* copied */
PalmDictList* dl );
#ifdef NODE_CAN_4 #ifdef NODE_CAN_4
void offerConvertOldDicts( PalmAppGlobals* globals ); void offerConvertOldDicts( PalmAppGlobals* globals );