openal: Don't free native path too early (duh)

This commit is contained in:
Elias Naur 2007-11-14 11:07:22 +00:00
parent 74ab4f7fa4
commit b19f24ec61
3 changed files with 3 additions and 3 deletions

View File

@ -48,13 +48,13 @@ void *NativeGetFunctionPointer(const char *function) {
void tryLoadLibrary(JNIEnv *env, jstring path) { void tryLoadLibrary(JNIEnv *env, jstring path) {
char *path_str = GetStringNativeChars(env, path); char *path_str = GetStringNativeChars(env, path);
printfDebugJava(env, "Testing '%s'", path_str); printfDebugJava(env, "Testing '%s'", path_str);
free(path_str);
handleOAL = dlopen(path_str, RTLD_LAZY); handleOAL = dlopen(path_str, RTLD_LAZY);
if (handleOAL != NULL) { if (handleOAL != NULL) {
printfDebugJava(env, "Found OpenAL at '%s'", path_str); printfDebugJava(env, "Found OpenAL at '%s'", path_str);
} else { } else {
throwException(env, "Could not load OpenAL library"); throwException(env, "Could not load OpenAL library");
} }
free(path_str);
} }
void UnLoadOpenAL() { void UnLoadOpenAL() {

View File

@ -93,12 +93,12 @@ void tryLoadLibrary(JNIEnv *env, jstring path) {
const char *path_str = (*env)->GetStringUTFChars(env, path, NULL); const char *path_str = (*env)->GetStringUTFChars(env, path, NULL);
printfDebugJava(env, "Testing '%s'", path_str); printfDebugJava(env, "Testing '%s'", path_str);
handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR); handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
(*env)->ReleaseStringUTFChars(env, path, path_str);
if (handleOAL != NULL) { if (handleOAL != NULL) {
printfDebugJava(env, "Found OpenAL at '%s'", path_str); printfDebugJava(env, "Found OpenAL at '%s'", path_str);
} else { } else {
throwException(env, "Could not load OpenAL library"); throwException(env, "Could not load OpenAL library");
} }
(*env)->ReleaseStringUTFChars(env, path, path_str);
} }
/** /**

View File

@ -55,12 +55,12 @@ void tryLoadLibrary(JNIEnv *env, jstring path) {
char *path_str = GetStringNativeChars(env, path); char *path_str = GetStringNativeChars(env, path);
printfDebugJava(env, "Testing '%s'", path_str); printfDebugJava(env, "Testing '%s'", path_str);
handleOAL = LoadLibrary(path_str); handleOAL = LoadLibrary(path_str);
free(path_str);
if (handleOAL != NULL) { if (handleOAL != NULL) {
printfDebugJava(env, "Found OpenAL at '%s'", path_str); printfDebugJava(env, "Found OpenAL at '%s'", path_str);
} else { } else {
throwException(env, "Could not load OpenAL library (%d)", GetLastError()); throwException(env, "Could not load OpenAL library (%d)", GetLastError());
} }
free(path_str);
} }
/** /**