From 01aed1f2efffa461e24d3bacdf0d499456b81ce6 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Fri, 17 Apr 2015 14:53:23 +0800 Subject: fixes typos --- src/storage/flexible_ngram_bdb.h | 4 ++-- src/storage/ngram_kyotodb.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/storage') 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 * & 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(); -- cgit