Dynamic loading

Started by CaptainJester, December 10, 2004, 01:50:34

Previous topic - Next topic

CaptainJester

I can't get dynamic loading to work for DevIL.  I don't have a lot of experience with 'C', so it might be something simple.  The code compiles fine, but I am getting an exception when I run it.  The exception occurs in native code.  Below is the code and the line that the exception occurs in.

void ext_InitializeClass(JNIEnv *env, jclass clazz, ExtGetProcAddressPROC gpa, int num_functions, JavaMethodAndExtFunction *functions) {
    JNINativeMethod *methods;
    JavaMethodAndExtFunction *function;
    void *ext_func_pointer;
    void **ext_function_pointer_pointer;
    JNINativeMethod *method;
    int i;
    if (clazz == NULL) {
        throwException(env, "Null class");
        return;
    }
    methods = (JNINativeMethod *)malloc(num_functions*sizeof(JNINativeMethod));
    for (i = 0; i < num_functions; i++) {
        function = functions + i;
        if (function->ext_function_name != NULL) {
            ext_func_pointer = gpa(function->ext_function_name);
            if (ext_func_pointer == NULL) {
                free(methods);
                throwException(env, "Missing driver symbols");
                return;
            }
            ext_function_pointer_pointer = function->ext_function_pointer;

//********** this is the line where the exception occurs
            *ext_function_pointer_pointer = ext_func_pointer;
//**************************************
        }
        method = methods + i;
        method->name = function->method_name;
        method->signature = function->signature;
        method->fnPtr = function->method_pointer;
    }
    (*env)->RegisterNatives(env, clazz, methods, num_functions);
    free(methods);
}


My code is in CVS in the files extil.c, extil.h, org_lwjgl_devil_IL.c.  In org_lwjgl_devil_IL.c, initNativeStubs is called which calls extil_InitializeClass in extil.c which calls ext_InitializeClass in common_tools.c.  This code is above.

Thanks.

ps.  I don't think the actual error is in the line above.  It is probably something I have done to cause it, but I don't know what that could be.
The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities.  We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)
8)