summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-09-06 12:04:48 +0800
committerPeng Wu <alexepico@gmail.com>2011-09-06 12:04:48 +0800
commita4901dd10796363b9f74db459965c8a9d4628ddb (patch)
tree4aa49e50fbae9e9aa158f634f5a3006d09fc61b9
parente2f06b37b9e2f8c1c1a9428c1619af4a8c5566c8 (diff)
downloadlibpinyin-a4901dd10796363b9f74db459965c8a9d4628ddb.zip
libpinyin-a4901dd10796363b9f74db459965c8a9d4628ddb.tar.gz
libpinyin-a4901dd10796363b9f74db459965c8a9d4628ddb.tar.xz
fixes compile and a bug
-rw-r--r--src/pinyin.cpp10
-rw-r--r--tests/test_pinyin.cpp5
2 files changed, 8 insertions, 7 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index 7bec3cb..822ebe9 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -116,11 +116,11 @@ bool pinyin_free_auxiliary_arrays(pinyin_context_t * context,
PinyinKeyVector * pinyin_keys,
CandidateConstraints * constraints,
MatchResults * match_results){
- g_array_free(*pinyin_keys, true);
+ g_array_free(*pinyin_keys, TRUE);
*pinyin_keys = NULL;
- g_array_free(*constraints, true);
+ g_array_free(*constraints, TRUE);
*constraints = NULL;
- g_array_free(*match_results, true);
+ g_array_free(*match_results, TRUE);
*match_results = NULL;
return true;
@@ -135,11 +135,11 @@ bool pinyin_set_options(pinyin_context_t * context,
return true;
}
-/* copy from pinyin_keys to m_pinyin_keys. */
+
bool pinyin_update_constraints(pinyin_context_t * context,
PinyinKeyVector pinyin_keys,
CandidateConstraints constraints){
- size_t key_len = pinyin_keys->len;
+ size_t key_len = constraints->len;
g_array_set_size(constraints, pinyin_keys->len);
for (size_t i = key_len; i < pinyin_keys->len; ++i ) {
lookup_constraint_t * constraint =
diff --git a/tests/test_pinyin.cpp b/tests/test_pinyin.cpp
index ce00f14..1009adb 100644
--- a/tests/test_pinyin.cpp
+++ b/tests/test_pinyin.cpp
@@ -46,9 +46,11 @@ int main(int argc, char * argv[]){
break;
pinyin_parse_more_fulls(context, linebuf, pinyin_keys);
- char * sentence = NULL;
+ pinyin_update_constraints(context, pinyin_keys, constraints);
pinyin_get_guessed_tokens(context, pinyin_keys, constraints,
match_results);
+
+ char * sentence = NULL;
pinyin_get_sentence (context, match_results, &sentence);
printf("%s\n", sentence);
g_free(sentence);
@@ -61,7 +63,6 @@ int main(int argc, char * argv[]){
pinyin_free_auxiliary_arrays
(context, &pinyin_keys, &constraints, &match_results);
pinyin_fini(context);
- g_array_free(pinyin_keys, TRUE);
free(linebuf);
return 0;
}