From 6c5a8a7b733263afc60c1bfd885802907e37070d Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 10 Oct 2012 18:06:51 +0800 Subject: fixes memory leak in chewing large table --- src/storage/chewing_large_table.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/storage/chewing_large_table.cpp b/src/storage/chewing_large_table.cpp index 0f3bd9c..8eb43d3 100644 --- a/src/storage/chewing_large_table.cpp +++ b/src/storage/chewing_large_table.cpp @@ -694,10 +694,11 @@ bool ChewingBitmapIndexLevel::load(MemoryChunk * chunk, table_offset_t offset, if (phrase_begin == phrase_end) /* null pointer */ continue; + /* after reset() all phrases are null pointer. */ ChewingLengthIndexLevel * phrases = new ChewingLengthIndexLevel; - phrases->load(chunk, phrase_begin, phrase_end - 1); m_chewing_length_indexes[k][l][m][n] = phrases; + phrases->load(chunk, phrase_begin, phrase_end - 1); assert(phrase_end <= end); assert(*(begin + phrase_end - 1) == c_separate); } @@ -758,7 +759,7 @@ bool ChewingLengthIndexLevel::load(MemoryChunk * chunk, table_offset_t offset, (begin + offset + sizeof(guint32)); table_offset_t phrase_begin, phrase_end = *index; - m_chewing_array_indexes = g_array_new(FALSE, TRUE, sizeof(void *)); + g_array_set_size(m_chewing_array_indexes, 0); for (guint32 i = 0; i < nindex; ++i) { phrase_begin = phrase_end; index++; -- cgit