summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-10-10 18:06:51 +0800
committerPeng Wu <alexepico@gmail.com>2012-10-10 18:06:51 +0800
commit6c5a8a7b733263afc60c1bfd885802907e37070d (patch)
treefc446e03896a3dc5107231246bac1750f7002751
parent6a5a4a3f6eb0d951c8f0813ec806e40ace097775 (diff)
downloadlibpinyin-6c5a8a7b733263afc60c1bfd885802907e37070d.zip
libpinyin-6c5a8a7b733263afc60c1bfd885802907e37070d.tar.gz
libpinyin-6c5a8a7b733263afc60c1bfd885802907e37070d.tar.xz
fixes memory leak in chewing large table
-rw-r--r--src/storage/chewing_large_table.cpp5
1 files 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++;