project_files/Android-build/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp
changeset 7554 e50b266ed85a
parent 6047 10011f051f9c
child 10017 de822cd3df3a
equal deleted inserted replaced
7552:1209e1c3c620 7554:e50b266ed85a
    25     //Get the String array from java
    25     //Get the String array from java
    26     int argc = env->GetArrayLength(strArray);
    26     int argc = env->GetArrayLength(strArray);
    27     char *argv[argc];
    27     char *argv[argc];
    28     jstring jstringArgv[argc];
    28     jstring jstringArgv[argc];
    29     for(int i = 0; i < argc; i++){
    29     for(int i = 0; i < argc; i++){
    30         jstringArgv[i] = (jstring)env->GetObjectArrayElement(strArray, i);  //get the element
    30 		jstringArgv[i] = (jstring)env->GetObjectArrayElement(strArray, i);  //get the element
    31 	argv[i] = (char*)malloc(sizeof(char) * env->GetStringLength(jstringArgv[i]));
    31 		argv[i] = (char*)malloc(env->GetStringUTFLength(jstringArgv[i]) + 1);
    32 	strcpy(argv[i], env->GetStringUTFChars(jstringArgv[i], JNI_FALSE)); //copy it to a mutable location
    32 		const char *str = env->GetStringUTFChars(jstringArgv[i], NULL);
    33 	//Don't release memory the JAVA GC will take care of it
    33 		strcpy(argv[i], str); //copy it to a mutable location
    34         //env->ReleaseStringChars(jstringArgv[i], (jchar*)argv[i]);           
    34         env->ReleaseStringUTFChars(jstringArgv[i], str);           
    35     }
    35     }
    36     
    36     
    37     /* Run the application code! */
    37     /* Run the application code! */
    38     int status;
    38     int status = SDL_main(argc, argv);
    39     status = SDL_main(argc, argv);
       
    40 
    39 
    41     //Clean up argv
    40     //Clean up argv
    42     for(int i = 0; i < argc; i++){
    41     for(int i = 0; i < argc; i++){
       
    42 		free(argv[i]);
    43     }
    43     }
    44 
       
    45     /* We exit here for consistency with other platforms. */
       
    46     //exit(status); Xeli: Or lets not crash the entire app.....
       
    47 }
    44 }
    48 
    45 
    49 /* vi: set ts=4 sw=4 expandtab: */
    46 /* vi: set ts=4 sw=4 expandtab: */