summaryrefslogtreecommitdiffstats
path: root/src/storage
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-10-11 13:47:31 +0800
committerPeng Wu <alexepico@gmail.com>2012-10-11 13:47:31 +0800
commitd23d9fca34dae6aea0cb6e8640ccf3f2cbc81256 (patch)
tree57ffe252c14a9a3b591b6a2b27a2bcfbb80c2837 /src/storage
parentae3def02deedae9ec711397f8a0698949fd16080 (diff)
downloadlibpinyin-d23d9fca34dae6aea0cb6e8640ccf3f2cbc81256.tar.gz
libpinyin-d23d9fca34dae6aea0cb6e8640ccf3f2cbc81256.tar.xz
libpinyin-d23d9fca34dae6aea0cb6e8640ccf3f2cbc81256.zip
fixes memory leak in facade chewing table
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/facade_chewing_table.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/storage/facade_chewing_table.h b/src/storage/facade_chewing_table.h
index da740c4..50683eb 100644
--- a/src/storage/facade_chewing_table.h
+++ b/src/storage/facade_chewing_table.h
@@ -39,6 +39,17 @@ private:
ChewingLargeTable * m_system_chewing_table;
ChewingLargeTable * m_user_chewing_table;
+ void reset() {
+ if (m_system_chewing_table) {
+ delete m_system_chewing_table;
+ m_system_chewing_table = NULL;
+ }
+
+ if (m_user_chewing_table) {
+ delete m_user_chewing_table;
+ m_user_chewing_table = NULL;
+ }
+ }
public:
/**
* FacadeChewingTable::FacadeChewingTable:
@@ -52,6 +63,16 @@ public:
}
/**
+ * FacadeChewingTable::~FacadeChewingTable:
+ *
+ * The destructor of the FacadeChewingTable.
+ *
+ */
+ ~FacadeChewingTable() {
+ reset();
+ }
+
+ /**
* FacadeChewingTable::set_options:
* @options: the pinyin options.
* @returns: whether the setting options is successful.
@@ -80,6 +101,8 @@ public:
*/
bool load(pinyin_option_t options, MemoryChunk * system,
MemoryChunk * user){
+ reset();
+
bool result = false;
if (system) {
m_system_chewing_table = new ChewingLargeTable(options);