diff options
author | 2013-01-11 03:52:00 -0800 | |
---|---|---|
committer | 2013-01-11 03:52:00 -0800 | |
commit | 53f9fe1b90932ea255ca604dd0f4e360af1d54a8 (patch) | |
tree | 8d62613a1a68980154128f5a8685dfed57fb8b55 /native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp | |
parent | 93fd1ac4fcf43001295151d62ad4733c37041c5a (diff) | |
parent | f6870cc82ddf394e94155322fcc7e4e2256bea66 (diff) | |
download | latinime-53f9fe1b90932ea255ca604dd0f4e360af1d54a8.tar.gz latinime-53f9fe1b90932ea255ca604dd0f4e360af1d54a8.tar.xz latinime-53f9fe1b90932ea255ca604dd0f4e360af1d54a8.zip |
am f6870cc8: Remove BinaryDictionary.MAX_PREDICTION and MAX_SPACES, and rename MAX_WORDS to MAX_RESULTS
* commit 'f6870cc82ddf394e94155322fcc7e4e2256bea66':
Remove BinaryDictionary.MAX_PREDICTION and MAX_SPACES, and rename MAX_WORDS to MAX_RESULTS
Diffstat (limited to 'native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp')
-rw-r--r-- | native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp index 4e34f98e9..d787327e6 100644 --- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp @@ -43,7 +43,7 @@ class ProximityInfo; static void releaseDictBuf(const void *dictBuf, const size_t length, const int fd); static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object, jstring sourceDir, - jlong dictOffset, jlong dictSize, jint maxWordLength, jint maxWords, jint maxPredictions) { + jlong dictOffset, jlong dictSize, jint maxWordLength) { PROF_OPEN; PROF_START(66); const jsize sourceDirUtf8Length = env->GetStringUTFLength(sourceDir); @@ -117,8 +117,7 @@ static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object, jstring releaseDictBuf(dictBuf, 0, 0); #endif // USE_MMAP_FOR_DICTIONARY } else { - dictionary = new Dictionary(dictBuf, static_cast<int>(dictSize), fd, adjust, maxWordLength, - maxWords, maxPredictions); + dictionary = new Dictionary(dictBuf, static_cast<int>(dictSize), fd, adjust, maxWordLength); } PROF_END(66); PROF_CLOSE; @@ -163,6 +162,14 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object, const jsize outputCodePointsLength = env->GetArrayLength(outputCodePointsArray); int outputCodePoints[outputCodePointsLength]; const jsize scoresLength = env->GetArrayLength(scoresArray); + + /* By the way, let's check the output array length here to make sure */ + if (scoresLength < MAX_RESULTS) { + ASSERT(false); + return 0; + } + + // Cont'd: Output values int scores[scoresLength]; const jsize spaceIndicesLength = env->GetArrayLength(spaceIndicesArray); int spaceIndices[spaceIndicesLength]; @@ -270,7 +277,7 @@ static void releaseDictBuf(const void *dictBuf, const size_t length, const int f } static JNINativeMethod sMethods[] = { - {"openNative", "(Ljava/lang/String;JJIII)J", + {"openNative", "(Ljava/lang/String;JJI)J", reinterpret_cast<void *>(latinime_BinaryDictionary_open)}, {"closeNative", "(J)V", reinterpret_cast<void *>(latinime_BinaryDictionary_close)}, {"getSuggestionsNative", "(JJJ[I[I[I[I[IIIZ[IZ[I[I[I[I)I", |