@@ -85,8 +85,8 @@ static SegmentInfo * segment_info = NULL;
8585
8686static char * shalloc (int bytes );
8787
88- static SharedIspellDict * copyIspellDict (IspellDict * dict , char * dictFile , char * affixFile );
89- static SharedStopList * copyStopList (StopList * list , char * stopFile );
88+ static SharedIspellDict * copyIspellDict (IspellDict * dict , char * dictFile , char * affixFile , int bytes );
89+ static SharedStopList * copyStopList (StopList * list , char * stopFile , int bytes );
9090
9191static int sizeIspellDict (IspellDict * dict , char * dictFile , char * affixFile );
9292static int sizeStopList (StopList * list , char * stopFile );
@@ -264,7 +264,7 @@ void init_shared_dict(DictInfo * info, char * dictFile, char * affFile, char * s
264264 }
265265
266266 /* fine, there's enough space - copy the dictionary */
267- shdict = copyIspellDict (dict , dictFile , affFile );
267+ shdict = copyIspellDict (dict , dictFile , affFile , size );
268268
269269 elog (INFO , "shared dictionary %s.dict / %s.affix loaded, used %d B, %ld B remaining" ,
270270 dictFile , affFile , size , segment_info -> available );
@@ -287,7 +287,7 @@ void init_shared_dict(DictInfo * info, char * dictFile, char * affFile, char * s
287287 }
288288
289289 /* fine, there's enough space - copy the stoplist */
290- shstop = copyStopList (& stoplist , stopFile );
290+ shstop = copyStopList (& stoplist , stopFile , size );
291291
292292 elog (INFO , "shared stoplist %s.stop loaded, used %d B, %ld B remaining" ,
293293 affFile , size , segment_info -> available );
@@ -690,19 +690,18 @@ int sizeAffixNode(AffixNode * node) {
690690}
691691
692692static
693- SharedStopList * copyStopList (StopList * list , char * stopFile ) {
693+ SharedStopList * copyStopList (StopList * list , char * stopFile , int size ) {
694694
695695 int i ;
696696 SharedStopList * copy = (SharedStopList * )shalloc (sizeof (SharedStopList ));
697697
698698 copy -> list .len = list -> len ;
699699 copy -> list .stop = (char * * )shalloc (sizeof (char * ) * list -> len );
700- copy -> stopFile = ( char * ) shalloc ( strlen ( stopFile ) + 1 );
701- memcpy ( copy -> stopFile , stopFile , strlen ( stopFile ) + 1 ) ;
700+ copy -> stopFile = shstrcpy ( stopFile );
701+ copy -> bytes = size ;
702702
703703 for (i = 0 ; i < list -> len ; i ++ ) {
704- copy -> list .stop [i ] = shalloc (strlen (list -> stop [i ]) + 1 );
705- memcpy (copy -> list .stop [i ], list -> stop [i ], strlen (list -> stop [i ]) + 1 );
704+ copy -> list .stop [i ] = shstrcpy (list -> stop [i ]);
706705 }
707706
708707 return copy ;
@@ -743,7 +742,7 @@ int countCMPDAffixes(CMPDAffix * affixes) {
743742}
744743
745744static
746- SharedIspellDict * copyIspellDict (IspellDict * dict , char * dictFile , char * affixFile ) {
745+ SharedIspellDict * copyIspellDict (IspellDict * dict , char * dictFile , char * affixFile , int size ) {
747746
748747 int i , cnt ;
749748
@@ -779,6 +778,8 @@ SharedIspellDict * copyIspellDict(IspellDict * dict, char * dictFile, char * aff
779778 memcpy (copy -> flagval , dict -> flagval , 255 );
780779 copy -> usecompound = dict -> usecompound ;
781780
781+ copy -> bytes = size ;
782+
782783 return copy ;
783784
784785}
0 commit comments