summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-10-09 13:58:49 +0800
committerPeng Wu <alexepico@gmail.com>2012-10-09 13:58:49 +0800
commit4f431b35d0241d57ce4edb48e78dd46eb82703e4 (patch)
treec84615bd7200ddca6e8153f8ea14cb9099ad390f
parentcf9791cfcce72347ac97c8766501fbaf1f8920b5 (diff)
downloadlibpinyin-4f431b35d0241d57ce4edb48e78dd46eb82703e4.zip
libpinyin-4f431b35d0241d57ce4edb48e78dd46eb82703e4.tar.gz
libpinyin-4f431b35d0241d57ce4edb48e78dd46eb82703e4.tar.xz
fixes memory leak in test_parser2
-rw-r--r--tests/storage/test_parser2.cpp11
1 files changed, 10 insertions, 1 deletions
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;
}