summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-03-31 14:10:12 +0800
committerPeng Wu <alexepico@gmail.com>2016-03-31 14:10:12 +0800
commit93f272f43dd5cea6d6b96e7569a281736f077c33 (patch)
tree8804ed365a25990935fc9dac3594a64e36652e12
parentd8a55692370a11440802b81814e026140f41ed9c (diff)
downloadlibpinyin-93f272f43dd5cea6d6b96e7569a281736f077c33.tar.gz
libpinyin-93f272f43dd5cea6d6b96e7569a281736f077c33.tar.xz
libpinyin-93f272f43dd5cea6d6b96e7569a281736f077c33.zip
fixes test_phrase
-rw-r--r--src/storage/phrase_large_table3_bdb.cpp8
-rw-r--r--src/storage/phrase_large_table3_kyotodb.cpp8
2 files changed, 9 insertions, 7 deletions
diff --git a/src/storage/phrase_large_table3_bdb.cpp b/src/storage/phrase_large_table3_bdb.cpp
index f8f0d82..a064850 100644
--- a/src/storage/phrase_large_table3_bdb.cpp
+++ b/src/storage/phrase_large_table3_bdb.cpp
@@ -55,6 +55,8 @@ void PhraseLargeTable3::reset() {
bool PhraseLargeTable3::attach(const char * dbfile, guint32 flags) {
reset();
+ m_entry = new PhraseTableEntry;
+
u_int32_t db_flags = attach_options(flags);
if (!dbfile)
@@ -68,8 +70,6 @@ bool PhraseLargeTable3::attach(const char * dbfile, guint32 flags) {
if (ret != 0)
return false;
- m_entry = new PhraseTableEntry;
-
return true;
}
@@ -77,6 +77,8 @@ bool PhraseLargeTable3::attach(const char * dbfile, guint32 flags) {
bool PhraseLargeTable3::load_db(const char * filename) {
reset();
+ m_entry = new PhraseTableEntry;
+
/* create in-memory db. */
int ret = db_create(&m_db, NULL, 0);
assert(0 == ret);
@@ -105,8 +107,6 @@ bool PhraseLargeTable3::load_db(const char * filename) {
if (tmp_db != NULL)
tmp_db->close(tmp_db, 0);
- m_entry = new PhraseTableEntry;
-
return true;
}
diff --git a/src/storage/phrase_large_table3_kyotodb.cpp b/src/storage/phrase_large_table3_kyotodb.cpp
index 71bb500..fa427dc 100644
--- a/src/storage/phrase_large_table3_kyotodb.cpp
+++ b/src/storage/phrase_large_table3_kyotodb.cpp
@@ -55,13 +55,15 @@ void PhraseLargeTable3::reset() {
/* attach method */
bool PhraseLargeTable3::attach(const char * dbfile, guint32 flags) {
reset();
+
+ m_entry = new PhraseTableEntry;
+
uint32_t mode = attach_options(flags);
if (!dbfile)
return false;
m_db = new TreeDB;
- m_entry = new PhraseTableEntry;
return m_db->open(dbfile, mode);
}
@@ -71,6 +73,8 @@ bool PhraseLargeTable3::attach(const char * dbfile, guint32 flags) {
bool PhraseLargeTable3::load_db(const char * filename) {
reset();
+ m_entry = new PhraseTableEntry;
+
/* create in-memory db. */
m_db = new ProtoTreeDB;
@@ -88,8 +92,6 @@ bool PhraseLargeTable3::load_db(const char * filename) {
tmp_db->close();
delete tmp_db;
- m_entry = new PhraseTableEntry;
-
return true;
}