dovecot-2.2: fts-lucene: Fix SnowballAnalyzer constructors
dovecot at dovecot.org
dovecot at dovecot.org
Fri Jun 13 13:13:54 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/d2ecee775c1f
changeset: 17490:d2ecee775c1f
user: Phil Carmody <phil at dovecot.fi>
date: Fri Jun 13 16:12:27 2014 +0300
description:
fts-lucene: Fix SnowballAnalyzer constructors
Coverity found the uninitialised pointers in the latter constructor (which
is never used - kill it?). In comparing the other constructor, the lack of
strdup() jumped out at me.
In fixing them both I migrated them to actual C++ initialisers, rather than
dumb assignments to uninitialised members. Also migrated to dovecot's i_*
functions. Also fixed indentation for the 3 functions touched.
Signed-off-by: Phil Carmody <phil at dovecot.fi>
diffstat:
src/plugins/fts-lucene/Snowball.cc | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diffs (51 lines):
diff -r f6e2fa1afa45 -r d2ecee775c1f src/plugins/fts-lucene/Snowball.cc
--- a/src/plugins/fts-lucene/Snowball.cc Fri Jun 13 15:14:44 2014 +0300
+++ b/src/plugins/fts-lucene/Snowball.cc Fri Jun 13 16:12:27 2014 +0300
@@ -26,27 +26,32 @@
CL_NS_DEF2(analysis,snowball)
/** Builds the named analyzer with no stop words. */
- SnowballAnalyzer::SnowballAnalyzer(normalizer_func_t *normalizer, const char* language) {
- this->language = strdup(language);
- this->normalizer = normalizer;
- stopSet = NULL;
- prevstream = NULL;
+ SnowballAnalyzer::SnowballAnalyzer(normalizer_func_t *_normalizer, const char* _language)
+ : language(i_strdup(_language)),
+ normalizer(_normalizer),
+ stopSet(NULL),
+ prevstream(NULL)
+ {
}
- SnowballAnalyzer::~SnowballAnalyzer(){
- if (prevstream) _CLDELETE(prevstream);
- _CLDELETE_CARRAY(language);
- if ( stopSet != NULL )
- _CLDELETE(stopSet);
+ SnowballAnalyzer::~SnowballAnalyzer()
+ {
+ if (prevstream)
+ _CLDELETE(prevstream);
+ i_free(language);
+ if ( stopSet != NULL )
+ _CLDELETE(stopSet);
}
/** Builds the named analyzer with the given stop words.
*/
- SnowballAnalyzer::SnowballAnalyzer(const char* language, const TCHAR** stopWords) {
- this->language = strdup(language);
-
- stopSet = _CLNEW CLTCSetList(true);
- StopFilter::fillStopTable(stopSet,stopWords);
+ SnowballAnalyzer::SnowballAnalyzer(const char* language, const TCHAR** stopWords)
+ : language(i_strdup(language)),
+ normalizer(NULL),
+ stopSet(_CLNEW CLTCSetList(true)),
+ prevstream(NULL)
+ {
+ StopFilter::fillStopTable(stopSet,stopWords);
}
TokenStream* SnowballAnalyzer::tokenStream(const TCHAR* fieldName, CL_NS(util)::Reader* reader) {
More information about the dovecot-cvs
mailing list