]> Nishi Git Mirror - serenade.git/commitdiff
ffi kinda works
authornishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Thu, 25 Apr 2024 05:45:08 +0000 (05:45 +0000)
committernishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Thu, 25 Apr 2024 05:45:08 +0000 (05:45 +0000)
git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@33 0f02c867-ac3d-714e-8a88-971ba1f6efcf

Serenade/ffi_binding.c

index 36dfabfee2ca7505a0f5855901da8f1907d817a5..24933da3f77b9e8a873028957f18c27ff61af500 100644 (file)
@@ -75,9 +75,9 @@ struct sn_generic* function_caller_handler(struct sn_interpreter* sn, int args,
        struct sn_generic* gen = malloc(sizeof(struct sn_generic));
        gen->type = SN_TYPE_VOID;
        struct ffi_info* info = (struct ffi_info*)gens[0]->ptr;
-       void** fargs = NULL;
+       void** fargs = malloc(sizeof(void*) * (info->argc + 1));
+       fargs[info->argc] = 0;
        if(info->argc > 0){
-               fargs = malloc(sizeof(void*) * info->argc);
                int i;
                for(i = 0; i < info->argc; i++){
                        void* ptr = NULL;
@@ -113,8 +113,8 @@ struct sn_generic* ffi_function_handler(struct sn_interpreter* sn, int args, str
 
                        info->ptr = gens[1]->ptr;
                        info->argc = args - 3;
-                       info->args = malloc(sizeof(ffi_type*) * (args - 3));
-                       info->argtypes = malloc(sizeof(ffi_type*) * (args - 2));
+                       info->args = malloc(sizeof(ffi_type*) * (args - 2));
+                       info->argtypes = malloc(sizeof(char*) * (args - 2));
 
                        ffi_type* ret = &ffi_type_void;