I think yes, but the top 12 examples I found all do something not illustrative like
JNIEXPORT jstring JCALL Java_com_foo_dumbImpl(JNIEnv* env, jobject thisObj)
{
return (*env)->NewStringUTF(env, "constant string");
}
so for posterity I will ask: this is bad, yes?
JNIEXPORT jstring JCALL Java_com_foo_dumbImpl(JNIEnv* env, jobject thisObj)
{
char *leak = malloc(1024);
leak[0] = '\0';
return (*env)->NewStringUTF(env, leak);
}
...and should be:
JNIEXPORT jstring JCALL Java_com_foo_dumbImpl(JNIEnv* env, jobject thisObj)
{
char *emptystring = NULL;
jstring r = NULL;
emptystring = malloc(1024);
emptystring[0] = '\0';
jstring = (*env)->NewStringUTF(env, emptystring);
free(emptystring); emptt
emptystring = NULL;
return r;
}