diff --git a/cocos2dx/platform/android/jni/IMEJni.cpp b/cocos2dx/platform/android/jni/IMEJni.cpp index 73b535e464..5e3937bb9e 100644 --- a/cocos2dx/platform/android/jni/IMEJni.cpp +++ b/cocos2dx/platform/android/jni/IMEJni.cpp @@ -60,13 +60,9 @@ extern "C" void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInsertText(JNIEnv* env, jobject thiz, jstring text) { - jboolean isCopy = 0; - const char* pszText = env->GetStringUTFChars(text, &isCopy); - if (isCopy) - { - cocos2d::CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); - env->ReleaseStringUTFChars(text, pszText); - } + const char* pszText = env->GetStringUTFChars(text, NULL); + cocos2d::CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); + env->ReleaseStringUTFChars(text, pszText); } void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeDeleteBackward(JNIEnv* env, jobject thiz) diff --git a/cocos2dx/platform/android/jni/JniHelper.cpp b/cocos2dx/platform/android/jni/JniHelper.cpp index c9690b2873..8d5e6cdc07 100644 --- a/cocos2dx/platform/android/jni/JniHelper.cpp +++ b/cocos2dx/platform/android/jni/JniHelper.cpp @@ -161,18 +161,14 @@ extern "C" { JNIEnv *env = 0; - jboolean isCopy; if (! getEnv(&env)) { return 0; } - const char* chars = env->GetStringUTFChars(jstr, &isCopy); + const char* chars = env->GetStringUTFChars(jstr, NULL); string ret(chars); - if (isCopy) - { - env->ReleaseStringUTFChars(jstr, chars); - } + env->ReleaseStringUTFChars(jstr, chars); return ret; } diff --git a/cocos2dx/platform/android/jni/MessageJni.cpp b/cocos2dx/platform/android/jni/MessageJni.cpp index 30d4ef2575..a14ca6040f 100644 --- a/cocos2dx/platform/android/jni/MessageJni.cpp +++ b/cocos2dx/platform/android/jni/MessageJni.cpp @@ -123,12 +123,8 @@ extern "C" ////////////////////////////////////////////////////////////////////////// void Java_org_cocos2dx_lib_Cocos2dxActivity_nativeSetPaths(JNIEnv* env, jobject thiz, jstring apkPath) { - const char* str; - jboolean isCopy; - str = env->GetStringUTFChars(apkPath, &isCopy); - if (isCopy) { - cocos2d::CCFileUtils::setResourcePath(str); - env->ReleaseStringUTFChars(apkPath, str); - } + const char* str = env->GetStringUTFChars(apkPath, NULL); + cocos2d::CCFileUtils::setResourcePath(str); + env->ReleaseStringUTFChars(apkPath, str); } } diff --git a/cocos2dx/platform/android/jni/SystemInfoJni.cpp b/cocos2dx/platform/android/jni/SystemInfoJni.cpp index 259358a7d8..759f4bd710 100644 --- a/cocos2dx/platform/android/jni/SystemInfoJni.cpp +++ b/cocos2dx/platform/android/jni/SystemInfoJni.cpp @@ -53,6 +53,7 @@ extern "C" t.env->DeleteLocalRef(t.classID); CCString *ret = new CCString(JniHelper::jstring2string(str).c_str()); ret->autorelease(); + t.env->DeleteLocalRef(str); LOGD("package name %s", ret->m_sString.c_str()); @@ -78,6 +79,7 @@ extern "C" t.env->DeleteLocalRef(t.classID); CCString *ret = new CCString(JniHelper::jstring2string(str).c_str()); ret->autorelease(); + t.env->DeleteLocalRef(str); LOGD("language name %s", ret.c_str());