I am learning to use C++ in Android.
The following function works well, but I do not know how to use ReleaseStringUTFChars(fileName, 0)
to release (or free) the memory allocated by env->GetStringUTFChars(input, 0);
Activity_stringFromJNI(
JNIEnv *env,
jobject, /* this */
jstring input) {
const char *str_C = env->GetStringUTFChars(input, 0);
char *data = funcX(str_C); // funcX allocates with malloc
// env->ReleaseStringUTFChars(input, str_C); ???
free(data); // Freeing funcX allocations
return env->NewStringUTF(someString.c_str());
}
Also, I have been trying to see the documentation, but I can't find it. How can I check if the memory is being released or freed correctly? Thanks!