summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-06-17 16:01:46 +0800
committerPeng Wu <alexepico@gmail.com>2013-06-17 16:01:46 +0800
commita6879516feb3e906ba1d0ed7847300bcfee7e092 (patch)
tree765c799b8996c190925c93d17c1ef73556cab9f2
parent5049635bc3b6c1e261c57774e79345876644dfa2 (diff)
downloadlibpinyin-a6879516feb3e906ba1d0ed7847300bcfee7e092.tar.gz
libpinyin-a6879516feb3e906ba1d0ed7847300bcfee7e092.tar.xz
libpinyin-a6879516feb3e906ba1d0ed7847300bcfee7e092.zip
fixes memory leaks
-rw-r--r--src/storage/phrase_index.cpp6
-rw-r--r--utils/storage/export_interpolation.cpp1
-rw-r--r--utils/utils_helper.h1
3 files changed, 7 insertions, 1 deletions
diff --git a/src/storage/phrase_index.cpp b/src/storage/phrase_index.cpp
index 930d606..5fe61c2 100644
--- a/src/storage/phrase_index.cpp
+++ b/src/storage/phrase_index.cpp
@@ -458,8 +458,12 @@ bool SubPhraseIndex::merge(PhraseIndexLogger * logger){
olditem.m_chunk.set_chunk(oldchunk.begin(), oldchunk.size(),
NULL);
- if (olditem != *tmpitem)
+
+ if (olditem != *tmpitem) {
+ delete tmpitem;
return false;
+ }
+
delete tmpitem;
break;
diff --git a/utils/storage/export_interpolation.cpp b/utils/storage/export_interpolation.cpp
index 99c76aa..c43eefb 100644
--- a/utils/storage/export_interpolation.cpp
+++ b/utils/storage/export_interpolation.cpp
@@ -136,6 +136,7 @@ bool gen_bigram(FILE * output, FacadePhraseIndex * phrase_index, Bigram * bigram
}
g_array_free(array, TRUE);
+ delete single_gram;
}
g_array_free(items, TRUE);
diff --git a/utils/utils_helper.h b/utils/utils_helper.h
index 86d5849..b91067b 100644
--- a/utils/utils_helper.h
+++ b/utils/utils_helper.h
@@ -85,6 +85,7 @@ static bool load_phrase_index(const pinyin_table_info_t * phrase_files,
bool retval = chunk->load(binfile);
if (!retval) {
fprintf(stderr, "load %s failed!\n", binfile);
+ delete chunk;
return false;
}