summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2015-04-17 14:53:23 +0800
committerPeng Wu <alexepico@gmail.com>2015-04-17 14:53:23 +0800
commit01aed1f2efffa461e24d3bacdf0d499456b81ce6 (patch)
tree399c3832cb073adecd4528f16d1e97a6cefe142c
parent87c1f5002150f24a45bf0b33f4fa0b7de44aaa2e (diff)
downloadlibpinyin-01aed1f2efffa461e24d3bacdf0d499456b81ce6.tar.gz
libpinyin-01aed1f2efffa461e24d3bacdf0d499456b81ce6.tar.xz
libpinyin-01aed1f2efffa461e24d3bacdf0d499456b81ce6.zip
fixes typos
-rw-r--r--src/storage/flexible_ngram_bdb.h4
-rw-r--r--src/storage/ngram_kyotodb.cpp3
2 files changed, 5 insertions, 2 deletions
diff --git a/src/storage/flexible_ngram_bdb.h b/src/storage/flexible_ngram_bdb.h
index 861667e..fd1e2ed 100644
--- a/src/storage/flexible_ngram_bdb.h
+++ b/src/storage/flexible_ngram_bdb.h
@@ -103,6 +103,7 @@ public:
if ( !dbfile )
return false;
+
int ret = db_create(&m_db, NULL, 0);
if ( ret != 0 )
assert(false);
@@ -163,6 +164,7 @@ public:
*/
bool load(phrase_token_t index,
FlexibleSingleGram<ArrayHeader, ArrayItem> * & single_gram){
+ single_gram = NULL;
if ( !m_db )
return false;
@@ -171,8 +173,6 @@ public:
db_key.data = &index;
db_key.size = sizeof(phrase_token_t);
- single_gram = NULL;
-
DBT db_data;
memset(&db_data, 0, sizeof(DBT));
int ret = m_db->get(m_db, NULL, &db_key, &db_data, 0);
diff --git a/src/storage/ngram_kyotodb.cpp b/src/storage/ngram_kyotodb.cpp
index 1cb72f4..f2771ca 100644
--- a/src/storage/ngram_kyotodb.cpp
+++ b/src/storage/ngram_kyotodb.cpp
@@ -141,6 +141,9 @@ bool Bigram::load(phrase_token_t index, SingleGram * & single_gram){
const char * kbuf = (char *) &index;
const int32_t vsiz = m_db->check(kbuf, sizeof(phrase_token_t));
+ /* -1 on failure. */
+ if (-1 == vsiz)
+ return false;
m_chunk.set_size(vsiz);
char * vbuf = (char *) m_chunk.begin();