mirror of
https://github.com/postgres/postgres.git
synced 2025-08-21 10:42:50 +03:00
Clean up temporary-memory management during ispell dictionary loading.
Add explicit initialization and cleanup functions to spell.c, and keep all working state in the already-existing ISpellDict struct. This lets us get rid of a static variable along with some extremely shaky assumptions about usage of child memory contexts. This commit is just code beautification and has no impact on functionality or performance, but it opens the way to a less-grotty implementation of Pavel's memory-saving hack, which will follow shortly.
This commit is contained in:
@@ -138,14 +138,6 @@ typedef struct
|
||||
int naffixes;
|
||||
AFFIX *Affix;
|
||||
|
||||
/*
|
||||
* Temporary array of all words in the dict file. Only used during
|
||||
* initialization
|
||||
*/
|
||||
SPELL **Spell;
|
||||
int nspell; /* number of valid entries in Spell array */
|
||||
int mspell; /* allocated length of Spell array */
|
||||
|
||||
AffixNode *Suffix;
|
||||
AffixNode *Prefix;
|
||||
|
||||
@@ -158,12 +150,26 @@ typedef struct
|
||||
|
||||
unsigned char flagval[256];
|
||||
bool usecompound;
|
||||
|
||||
/*
|
||||
* Remaining fields are only used during dictionary construction;
|
||||
* they are set up by NIStartBuild and cleared by NIFinishBuild.
|
||||
*/
|
||||
MemoryContext buildCxt; /* temp context for construction */
|
||||
|
||||
/* Temporary array of all words in the dict file */
|
||||
SPELL **Spell;
|
||||
int nspell; /* number of valid entries in Spell array */
|
||||
int mspell; /* allocated length of Spell array */
|
||||
} IspellDict;
|
||||
|
||||
extern TSLexeme *NINormalizeWord(IspellDict *Conf, char *word);
|
||||
|
||||
extern void NIStartBuild(IspellDict *Conf);
|
||||
extern void NIImportAffixes(IspellDict *Conf, const char *filename);
|
||||
extern void NIImportDictionary(IspellDict *Conf, const char *filename);
|
||||
extern void NISortDictionary(IspellDict *Conf);
|
||||
extern void NISortAffixes(IspellDict *Conf);
|
||||
extern void NIFinishBuild(IspellDict *Conf);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user