summaryrefslogtreecommitdiffstats
path: root/src/storage
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-10-11 13:36:24 +0800
committerPeng Wu <alexepico@gmail.com>2012-10-11 13:36:24 +0800
commitae3def02deedae9ec711397f8a0698949fd16080 (patch)
treebca6d854701bf41511a392f56f75b5e889480191 /src/storage
parent995a9df0af809ee2b21b60b32ae424cf57f378e2 (diff)
downloadlibpinyin-ae3def02deedae9ec711397f8a0698949fd16080.tar.gz
libpinyin-ae3def02deedae9ec711397f8a0698949fd16080.tar.xz
libpinyin-ae3def02deedae9ec711397f8a0698949fd16080.zip
fixes memory leak in facade phrase table2
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/facade_phrase_table2.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/storage/facade_phrase_table2.h b/src/storage/facade_phrase_table2.h
index 3f40f57..b9bc9ca 100644
--- a/src/storage/facade_phrase_table2.h
+++ b/src/storage/facade_phrase_table2.h
@@ -38,6 +38,18 @@ private:
PhraseLargeTable2 * m_system_phrase_table;
PhraseLargeTable2 * m_user_phrase_table;
+ void reset(){
+ if (m_system_phrase_table) {
+ delete m_system_phrase_table;
+ m_system_phrase_table = NULL;
+ }
+
+ if (m_user_phrase_table) {
+ delete m_user_phrase_table;
+ m_user_phrase_table = NULL;
+ }
+ }
+
public:
/**
* FacadePhraseTable2::FacadePhraseTable2:
@@ -51,6 +63,16 @@ public:
}
/**
+ * FacadePhraseTable2::~FacadePhraseTable2:
+ *
+ * The destructor of the FacadePhraseTable2.
+ *
+ */
+ ~FacadePhraseTable2() {
+ reset();
+ }
+
+ /**
* FacadePhraseTable2::load:
* @system: the memory chunk of the system phrase table.
* @user: the memory chunk of the user phrase table.
@@ -60,6 +82,8 @@ public:
*
*/
bool load(MemoryChunk * system, MemoryChunk * user) {
+ reset();
+
bool result = false;
if (system) {
m_system_phrase_table = new PhraseLargeTable2;