diff --git a/apps/openmw/android_commandLine.cpp b/apps/openmw/android_commandLine.cpp index bb95a0534..129e63797 100644 --- a/apps/openmw/android_commandLine.cpp +++ b/apps/openmw/android_commandLine.cpp @@ -1,18 +1,20 @@ #include "android_commandLine.h" #include "string.h" - const char *argvData[15]; - int argcData; + + +const char **argvData; +int argcData; JNIEXPORT void JNICALL Java_ui_activity_GameActivity_commandLine(JNIEnv *env, jobject obj, jint argc, jobjectArray stringArray) { jboolean iscopy; argcData = (int) argc; - argvData[0]="openmw"; - for (int i = 0; i < argcData; i++) { - jstring string = (jstring) (*env).GetObjectArrayElement(stringArray, i); - argvData[i+1] = (env)->GetStringUTFChars(string, &iscopy); + argvData= new const char * [argcData+1]; + argvData[0] = "openmw"; + for (int i = 1; i < argcData+1; i++) { + jstring string = (jstring) (*env).GetObjectArrayElement(stringArray, i-1); + argvData[i] = (env)->GetStringUTFChars(string, &iscopy); } - } diff --git a/apps/openmw/android_main.c b/apps/openmw/android_main.c index 0cfb8dcfa..d3a6ca63a 100644 --- a/apps/openmw/android_main.c +++ b/apps/openmw/android_main.c @@ -12,7 +12,7 @@ extern void SDL_Android_Init(JNIEnv* env, jclass cls); extern int argcData; -extern const char *argvData[15]; +extern const char **argvData; int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj) { @@ -26,6 +26,7 @@ int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, int status; status = main(argcData+1, argvData); + free (argvData); /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */ /* exit(status); */