[gjs] gi: calculate out_arg_cvalues length correctly



commit 7fddc7f91589ef59e6920d508c73f8fa7315a8f7
Author: Tommi Komulainen <tko litl com>
Date:   Tue Mar 2 12:39:40 2010 +0000

    gi: calculate out_arg_cvalues length correctly
    
    Make sure to allocate out_arg_cvalues also for functions with single out
    argument and no return value.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=611591

 gi/function.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/gi/function.c b/gi/function.c
index 93a429b..fbca794 100644
--- a/gi/function.c
+++ b/gi/function.c
@@ -530,10 +530,17 @@ gjs_invoke_c_function(JSContext      *context,
         return JS_FALSE;
     }
 
+    g_callable_info_load_return_type( (GICallableInfo*) function->info, &return_info);
+    return_tag = g_type_info_get_tag(&return_info);
+
     in_args_len = function->invoker.cif.nargs;
-    out_args_len = function->js_out_argc > 1 ? function->js_out_argc - 1 : 0;
+    out_args_len = function->js_out_argc;
     inout_args_len = function->inout_argc;
 
+    if (return_tag != GI_TYPE_TAG_VOID) {
+        --out_args_len;
+    }
+
     in_arg_cvalues = g_newa(GArgument, in_args_len);
     in_arg_pointers = g_newa(gpointer, in_args_len);
     out_arg_cvalues = g_newa(GArgument, out_args_len);
@@ -690,10 +697,6 @@ gjs_invoke_c_function(JSContext      *context,
     g_slist_free(data_for_notify);
     g_slist_free(callback_arg_indices);
 
-    g_callable_info_load_return_type( (GICallableInfo*) function->info, &return_info);
-
-    return_tag = g_type_info_get_tag(&return_info);
-
     *rval = JSVAL_VOID;
 
     next_rval = 0; /* index into return_values */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]