am 063c3e21: Fix memset() bugs

* commit '063c3e2171e546957d8c40575740c29f234e307c':
  Fix memset() bugs
main
Ken Wakasa 2012-08-10 06:21:31 -07:00 committed by Android Git Automerger
commit ec1e373a20
2 changed files with 6 additions and 6 deletions

View File

@ -170,10 +170,10 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object,
int spaceIndices[spaceIndicesLength]; int spaceIndices[spaceIndicesLength];
const jsize outputTypesLength = env->GetArrayLength(outputTypesArray); const jsize outputTypesLength = env->GetArrayLength(outputTypesArray);
int outputTypes[outputTypesLength]; int outputTypes[outputTypesLength];
memset(outputChars, 0, outputCharsLength); memset(outputChars, 0, outputCharsLength * sizeof(outputChars[0]));
memset(scores, 0, scoresLength); memset(scores, 0, scoresLength * sizeof(scores[0]));
memset(spaceIndices, 0, spaceIndicesLength); memset(spaceIndices, 0, spaceIndicesLength * sizeof(spaceIndices[0]));
memset(outputTypes, 0, outputTypesLength); memset(outputTypes, 0, outputTypesLength * sizeof(outputTypes[0]));
int count; int count;
if (isGesture || arraySize > 1) { if (isGesture || arraySize > 1) {

View File

@ -34,7 +34,7 @@ static inline void safeGetOrFillZeroIntArrayRegion(JNIEnv *env, jintArray jArray
if (jArray && buffer) { if (jArray && buffer) {
env->GetIntArrayRegion(jArray, 0, len, buffer); env->GetIntArrayRegion(jArray, 0, len, buffer);
} else if (buffer) { } else if (buffer) {
memset(buffer, 0, len); memset(buffer, 0, len * sizeof(jint));
} }
} }
@ -43,7 +43,7 @@ static inline void safeGetOrFillZeroFloatArrayRegion(JNIEnv *env, jfloatArray jA
if (jArray && buffer) { if (jArray && buffer) {
env->GetFloatArrayRegion(jArray, 0, len, buffer); env->GetFloatArrayRegion(jArray, 0, len, buffer);
} else if (buffer) { } else if (buffer) {
memset(buffer, 0, len); memset(buffer, 0, len * sizeof(jfloat));
} }
} }