summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-06-21 10:25:58 +0800
committerPeng Wu <alexepico@gmail.com>2012-06-21 11:30:17 +0800
commit96f2c4d4321663d9bf817f01c5102b8ac59481fa (patch)
tree3571e6bb142468e4c77de81cf72ac8f2002c0d43
parent19fd61c47b7d3ecb116636a62a76668bbb38133e (diff)
downloadlibpinyin-96f2c4d4321663d9bf817f01c5102b8ac59481fa.tar.gz
libpinyin-96f2c4d4321663d9bf817f01c5102b8ac59481fa.tar.xz
libpinyin-96f2c4d4321663d9bf817f01c5102b8ac59481fa.zip
add assert
-rw-r--r--src/pinyin.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index a6c888c..2b384c2 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -52,6 +52,9 @@ struct _pinyin_context_t{
};
static gchar * get_dbin_filename(const gchar * filename){
+ /* check the suffix. */
+ assert(g_str_has_suffix(filename, ".bin"));
+
/* compute the delta bin file name. */
gchar * tmp = g_strdup(filename);
tmp[strlen(tmp) - 4] = '\0'; /* remove ".bin" */
@@ -280,6 +283,9 @@ bool pinyin_save(pinyin_context_t * context){
if (NULL == phrasefilename)
continue;
+ /* check the suffix. */
+ assert(g_str_has_suffix(phrasefilename, ".bin"));
+
MemoryChunk * chunk = new MemoryChunk;
MemoryChunk * log = new MemoryChunk;
/* check bin file in system dir. */
@@ -372,7 +378,11 @@ void pinyin_fini(pinyin_context_t * context){
for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
gchar * & phrasefilename = context->m_phrase_indices[i];
+
if (phrasefilename) {
+ /* check the suffix. */
+ assert(g_str_has_suffix(phrasefilename, ".bin"));
+
g_free(phrasefilename);
}
}