diff options
author | Peng Wu <alexepico@gmail.com> | 2012-09-01 11:50:31 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-09-01 11:50:31 +0800 |
commit | 4f3e1e5075b998b08dcec7d11d85ffb098ca9dcb (patch) | |
tree | aa6b01685f554047ec6ff3413b0e843a3f36b781 | |
parent | ccd4c3fca513db530e0be91e4830df6e6c0555f4 (diff) | |
download | libpinyin-4f3e1e5075b998b08dcec7d11d85ffb098ca9dcb.tar.gz libpinyin-4f3e1e5075b998b08dcec7d11d85ffb098ca9dcb.tar.xz libpinyin-4f3e1e5075b998b08dcec7d11d85ffb098ca9dcb.zip |
write prepare/destroy tokens
-rw-r--r-- | src/storage/phrase_index.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/storage/phrase_index.h b/src/storage/phrase_index.h index d59865d..64fcec5 100644 --- a/src/storage/phrase_index.h +++ b/src/storage/phrase_index.h @@ -691,6 +691,47 @@ public: } /** + * FacadePhraseIndex::prepare_tokens: + * @tokens: the tokens to be prepared. + * @returns: whether the prepare operation is successful. + * + * Prepare the tokens. + * + */ + bool prepare_tokens(PhraseTokens tokens) { + /* assume memset(tokens, 0, sizeof(tokens)); */ + for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) { + GArray * & token = tokens[i]; + assert(NULL == token); + + SubPhraseIndex * sub_phrase = m_sub_phrase_indices[i]; + if (sub_phrase) { + token = g_array_new(FALSE, FALSE, sizeof(phrase_token_t)); + } + } + return true; + } + + /** + * FacadePhraseIndex::destroy_tokens: + * @tokens: the tokens to be destroyed. + * @returns: whether the destroy operation is successful. + * + * Destroy the tokens. + * + */ + bool destroy_tokens(PhraseTokens tokens) { + for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) { + GArray * & token = tokens[i]; + if (token) { + g_array_free(token, TRUE); + token = NULL; + } + } + return true; + } + + /** * FacadePhraseIndex::create_sub_phrase: * @index: the phrase index to be created. * @returns: the result of the create operation. |