summaryrefslogtreecommitdiffstats
path: root/src/pinyin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pinyin.cpp')
-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);
}
}