From 9c03a1fdf89ce6fcbc8d75c17af3ba22956eefc9 Mon Sep 17 00:00:00 2001 From: nishi Date: Thu, 25 Apr 2024 05:45:08 +0000 Subject: [PATCH] ffi kinda works git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@33 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- Serenade/ffi_binding.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Serenade/ffi_binding.c b/Serenade/ffi_binding.c index 36dfabf..24933da 100644 --- a/Serenade/ffi_binding.c +++ b/Serenade/ffi_binding.c @@ -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; -- 2.43.0