summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaotao Duan <xiaotao@google.com>2009-05-04 18:43:18 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-05-04 18:43:18 -0700
commit4358e82119396b1bbe8bcd905e52e714ecf2b055 (patch)
treec1445d2862c2f5427b5fc2c2a4eac7a7846383e1
parenta454b4227185aca2a3f0f51efe1699b65ba438d9 (diff)
parentc78dcdec607b4f50738a5b84fa170403e23c75ad (diff)
downloadPinyinIME-4358e82119396b1bbe8bcd905e52e714ecf2b055.tar.gz
am c78dcde: Replace unnecessary realloc()
Merge commit 'c78dcdec607b4f50738a5b84fa170403e23c75ad' * commit 'c78dcdec607b4f50738a5b84fa170403e23c75ad': Replace unnecessary realloc()
-rw-r--r--jni/share/userdict.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/jni/share/userdict.cpp b/jni/share/userdict.cpp
index 5064296..c3c7c98 100644
--- a/jni/share/userdict.cpp
+++ b/jni/share/userdict.cpp
@@ -1739,8 +1739,7 @@ int UserDict::put_lemmas_no_sync_from_utf16le_string(char16 * lemmas, int len) {
char16 * p = ptr, * py16 = ptr;
char16 * hz16 = NULL;
int py16_len = 0;
- uint16 * splid = NULL;
- int splid_size = 0;
+ uint16 splid[kMaxLemmaSize];
int splid_len = 0;
int hz16_len = 0;
char16 * fr16 = NULL;
@@ -1759,16 +1758,12 @@ int UserDict::put_lemmas_no_sync_from_utf16le_string(char16 * lemmas, int len) {
if (p - ptr == len)
break;
py16_len = p - py16;
- if (splid_size < splid_len) {
- char16 * tid = (char16*)realloc(splid, splid_len * 2);
- if (!tid)
- break;
- splid = tid;
- splid_size = splid_len * 2;
+ if (kMaxLemmaSize < splid_len) {
+ break;
}
bool is_pre;
int splidl = spl_parser->splstr16_to_idxs_f(
- py16, py16_len, splid, NULL, splid_size, is_pre);
+ py16, py16_len, splid, NULL, kMaxLemmaSize, is_pre);
if (splidl != splid_len)
break;
// Phrase