From 6a5a4a3f6eb0d951c8f0813ec806e40ace097775 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 10 Oct 2012 17:02:52 +0800 Subject: fixes memory leak in phrase large table2 --- src/storage/phrase_large_table2.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/storage/phrase_large_table2.cpp b/src/storage/phrase_large_table2.cpp index 56180d1..94edfe0 100644 --- a/src/storage/phrase_large_table2.cpp +++ b/src/storage/phrase_large_table2.cpp @@ -109,10 +109,11 @@ PhraseBitmapIndexLevel2::PhraseBitmapIndexLevel2(){ void PhraseBitmapIndexLevel2::reset(){ for ( size_t i = 0; i < PHRASE_NUMBER_OF_BITMAP_INDEX; i++){ - PhraseLengthIndexLevel2 * length_array = + PhraseLengthIndexLevel2 * & length_array = m_phrase_length_indexes[i]; if ( length_array ) delete length_array; + length_array = NULL; } } @@ -474,8 +475,11 @@ bool PhraseBitmapIndexLevel2::load(MemoryChunk * chunk, phrase_end = *index; if ( phrase_begin == phrase_end ) //null pointer continue; + + /* after reset() all phrases are null pointer. */ PhraseLengthIndexLevel2 * phrases = new PhraseLengthIndexLevel2; m_phrase_length_indexes[i] = phrases; + phrases->load(chunk, phrase_begin, phrase_end - 1); assert( phrase_end <= end ); assert( *(buf_begin + phrase_end - 1) == c_separate); @@ -524,7 +528,7 @@ bool PhraseLengthIndexLevel2::load(MemoryChunk * chunk, (buf_begin + offset + sizeof(guint32)); table_offset_t phrase_begin, phrase_end = *index; - m_phrase_array_indexes = g_array_new(FALSE, TRUE, sizeof(void *)); + g_array_set_size(m_phrase_array_indexes, 0); for (size_t i = 1; i <= nindex; ++i) { phrase_begin = phrase_end; index++; -- cgit