forked from mirror/openmw-tes3mp
Merge remote-tracking branch 'sandstranger/release-jni-memory'
This commit is contained in:
commit
c032113247
3 changed files with 15 additions and 7 deletions
|
@ -1,11 +1,15 @@
|
||||||
#include "android_commandLine.h"
|
#include "android_commandLine.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char **argvData;
|
const char **argvData;
|
||||||
int argcData;
|
int argcData;
|
||||||
|
|
||||||
|
extern "C" void releaseArgv();
|
||||||
|
|
||||||
|
void releaseArgv() {
|
||||||
|
delete[] argvData;
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_ui_activity_GameActivity_commandLine(JNIEnv *env,
|
JNIEXPORT void JNICALL Java_ui_activity_GameActivity_commandLine(JNIEnv *env,
|
||||||
jobject obj, jint argc, jobjectArray stringArray) {
|
jobject obj, jint argc, jobjectArray stringArray) {
|
||||||
jboolean iscopy;
|
jboolean iscopy;
|
||||||
|
@ -13,8 +17,11 @@ JNIEXPORT void JNICALL Java_ui_activity_GameActivity_commandLine(JNIEnv *env,
|
||||||
argvData = new const char *[argcData + 1];
|
argvData = new const char *[argcData + 1];
|
||||||
argvData[0] = "openmw";
|
argvData[0] = "openmw";
|
||||||
for (int i = 1; i < argcData + 1; i++) {
|
for (int i = 1; i < argcData + 1; i++) {
|
||||||
jstring string = (jstring) (*env).GetObjectArrayElement(stringArray, i-1);
|
jstring string = (jstring) (env)->GetObjectArrayElement(stringArray,
|
||||||
|
i - 1);
|
||||||
argvData[i] = (env)->GetStringUTFChars(string, &iscopy);
|
argvData[i] = (env)->GetStringUTFChars(string, &iscopy);
|
||||||
|
(env)->DeleteLocalRef(string);
|
||||||
}
|
}
|
||||||
|
(env)->DeleteLocalRef(stringArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
|
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
|
||||||
extern int argcData;
|
extern int argcData;
|
||||||
extern const char **argvData;
|
extern const char **argvData;
|
||||||
|
void releaseArgv();
|
||||||
|
|
||||||
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
|
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
|
||||||
jobject obj) {
|
jobject obj) {
|
||||||
|
@ -26,8 +27,7 @@ int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = main(argcData+1, argvData);
|
status = main(argcData+1, argvData);
|
||||||
free (argvData);
|
releaseArgv();
|
||||||
|
|
||||||
/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
|
/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
|
||||||
/* exit(status); */
|
/* exit(status); */
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ JNIEXPORT void JNICALL Java_ui_activity_GameActivity_getPathToJni(JNIEnv *env, j
|
||||||
{
|
{
|
||||||
jboolean iscopy;
|
jboolean iscopy;
|
||||||
Buffer::setData((env)->GetStringUTFChars(prompt, &iscopy));
|
Buffer::setData((env)->GetStringUTFChars(prompt, &iscopy));
|
||||||
|
(env)->DeleteLocalRef(prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
Loading…
Reference in a new issue