summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-02-05 16:45:00 +0800
committerPeng Wu <alexepico@gmail.com>2016-02-05 16:45:00 +0800
commitfa4f8cdc44f3825c5532227e90c6d9ed8c6fbe0d (patch)
tree029a062277fd2c5ed01a7e49883426ab9ffd2d19
parent21f1ccd98393aa1d4e63766cf4edf633b1d49d3c (diff)
downloadlibpinyin-fa4f8cdc44f3825c5532227e90c6d9ed8c6fbe0d.tar.gz
libpinyin-fa4f8cdc44f3825c5532227e90c6d9ed8c6fbe0d.tar.xz
libpinyin-fa4f8cdc44f3825c5532227e90c6d9ed8c6fbe0d.zip
fixes typos
-rw-r--r--src/storage/ngram_kyotodb.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/storage/ngram_kyotodb.cpp b/src/storage/ngram_kyotodb.cpp
index 20d0ebc..3de3e5b 100644
--- a/src/storage/ngram_kyotodb.cpp
+++ b/src/storage/ngram_kyotodb.cpp
@@ -74,21 +74,22 @@ public:
bool Bigram::load_db(const char * dbfile){
reset();
- /* create on-memory db. */
+ /* create in-memory db. */
m_db = new ProtoHashDB;
- if ( !m_db->open("-", ProtoHashDB::OWRITER|ProtoHashDB::OCREATE) )
+ if ( !m_db->open("-", BasicDB::OREADER|BasicDB::OWRITER|BasicDB::OCREATE) )
return false;
/* load db into memory. */
BasicDB * tmp_db = new HashDB;
- tmp_db->open(dbfile, BasicDB::OREADER);
+ if (!tmp_db->open(dbfile, BasicDB::OREADER))
+ return false;
CopyVisitor visitor(m_db);
tmp_db->iterate(&visitor, false);
- if (tmp_db != NULL)
- tmp_db->close();
+ tmp_db->close();
+ delete tmp_db;
return true;
}
@@ -107,10 +108,9 @@ bool Bigram::save_db(const char * dbfile){
CopyVisitor visitor(tmp_db);
m_db->iterate(&visitor, false);
- if (tmp_db != NULL) {
- tmp_db->synchronize();
- tmp_db->close();
- }
+ tmp_db->synchronize();
+ tmp_db->close();
+ delete tmp_db;
return true;
}