fixes memory leaks
authorPeng Wu <alexepico@gmail.com>
Mon, 17 Jun 2013 08:01:46 +0000 (16:01 +0800)
committerPeng Wu <alexepico@gmail.com>
Mon, 17 Jun 2013 08:01:46 +0000 (16:01 +0800)
src/storage/phrase_index.cpp
utils/storage/export_interpolation.cpp
utils/utils_helper.h

index 930d606..5fe61c2 100644 (file)
@@ -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;
index 99c76aa..c43eefb 100644 (file)
@@ -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);
index 86d5849..b91067b 100644 (file)
@@ -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;
         }