From 4f431b35d0241d57ce4edb48e78dd46eb82703e4 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 9 Oct 2012 13:58:49 +0800 Subject: fixes memory leak in test_parser2 --- tests/storage/test_parser2.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/storage/test_parser2.cpp b/tests/storage/test_parser2.cpp index 7c7058c..24e38c7 100644 --- a/tests/storage/test_parser2.cpp +++ b/tests/storage/test_parser2.cpp @@ -56,6 +56,7 @@ int main(int argc, char * argv[]) { ChewingKeyVector keys = g_array_new(FALSE, FALSE, sizeof(ChewingKey)); ChewingKeyRestVector key_rests = g_array_new(FALSE, FALSE, sizeof(ChewingKeyRest)); + pinyin_option_t options = PINYIN_CORRECT_ALL | USE_TONE | USE_RESPLIT_TABLE; int i = 1; @@ -127,8 +128,11 @@ int main(int argc, char * argv[]) { &g_array_index(keys, ChewingKey, i); ChewingKeyRest * key_rest = &g_array_index(key_rests, ChewingKeyRest, i); - printf("%s %d %d\t", key->get_pinyin_string(), + + gchar * pinyins = key->get_pinyin_string(); + printf("%s %d %d\t", pinyins, key_rest->m_raw_begin, key_rest->m_raw_end); + g_free(pinyins); } printf("\n"); #endif @@ -138,5 +142,10 @@ int main(int argc, char * argv[]) { if (linebuf) free(linebuf); + delete parser; + + g_array_free(key_rests, TRUE); + g_array_free(keys, TRUE); + return 0; } -- cgit