From 027b54b4cadda5af698e95b9ef27801f197cba49 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 20 Jul 2011 19:25:12 +0800 Subject: add class destructor to phrase lookup --- src/lookup/phrase_lookup.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/lookup') diff --git a/src/lookup/phrase_lookup.cpp b/src/lookup/phrase_lookup.cpp index 96069da..c51fabc 100644 --- a/src/lookup/phrase_lookup.cpp +++ b/src/lookup/phrase_lookup.cpp @@ -43,6 +43,23 @@ PhraseLookup::PhraseLookup(PhraseLargeTable * phrase_table, m_steps_content = g_ptr_array_new(); } +PhraseLookup::~PhraseLookup(){ + //free m_steps_index + for ( size_t i = 0; i < m_steps_index->len; ++i){ + GHashTable * table = (GHashTable *) g_ptr_array_index(m_steps_index, i); + g_hash_table_destroy(table); + } + g_ptr_array_free(m_steps_index, TRUE); + m_steps_index = NULL; + + //free m_steps_content + for ( size_t i = 0; i < m_steps_content->len; ++i){ + GArray * array = (GArray *) g_ptr_array_index(m_steps_content, i); + g_array_free(array, TRUE); + } + g_ptr_array_free(m_steps_content, TRUE); +} + bool PhraseLookup::get_best_match(int sentence_length, utf16_t sentence[], MatchResults & results){ m_sentence_length = sentence_length; -- cgit