[pygobject] invoke/closure: reduce g_slice_alloc usage



commit f72b6434de82ffa1950ff45a4daf80c84f58eca6
Author: Christoph Reiter <creiter src gnome org>
Date:   Sat Sep 26 21:25:38 2015 +0200

    invoke/closure: reduce g_slice_alloc usage
    
    Instead of allocating multiple arrays, combine argument
    data in a new PyGIInvokeArgState and allocate it in one go.
    
    This reduces CPU time by 20% for simple functions and by 15%
    for closures.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=750658

 gi/pygi-array.c               |    6 +-
 gi/pygi-closure.c             |   99 ++++++++++++++++++-----------------------
 gi/pygi-invoke-state-struct.h |   34 ++++++++------
 gi/pygi-invoke.c              |   50 ++++++--------------
 gi/pygi-marshal-cleanup.c     |   10 ++--
 5 files changed, 86 insertions(+), 113 deletions(-)
---
diff --git a/gi/pygi-array.c b/gi/pygi-array.c
index 121992b..1f62b94 100644
--- a/gi/pygi-array.c
+++ b/gi/pygi-array.c
@@ -386,7 +386,7 @@ array_success:
         PyGIArgCache *child_cache =
             _pygi_callable_cache_get_arg (callable_cache, array_cache->len_arg_index);
 
-        if (!gi_argument_from_py_ssize_t (&state->arg_values[child_cache->c_arg_index],
+        if (!gi_argument_from_py_ssize_t (&state->args[child_cache->c_arg_index].arg_value,
                                           length,
                                           child_cache->type_tag)) {
             goto err;
@@ -530,7 +530,7 @@ _pygi_marshal_to_py_array (PyGIInvokeState   *state,
                 len = g_strv_length ((gchar **)arg->v_pointer);
             }
         } else {
-            GIArgument *len_arg = &state->arg_values[array_cache->len_arg_index];
+            GIArgument *len_arg = &state->args[array_cache->len_arg_index].arg_value;
             PyGIArgCache *arg_cache = _pygi_callable_cache_get_arg (callable_cache,
                                                                     array_cache->len_arg_index);
 
@@ -686,7 +686,7 @@ _wrap_c_array (PyGIInvokeState   *state,
     } else if (array_cache->is_zero_terminated) {
         len = g_strv_length ((gchar **)data);
     } else if (array_cache->len_arg_index >= 0) {
-        GIArgument *len_arg = &state->arg_values[array_cache->len_arg_index];
+        GIArgument *len_arg = &state->args[array_cache->len_arg_index].arg_value;
         len = len_arg->v_long;
     }
 
diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c
index 509ff56..f54d886 100644
--- a/gi/pygi-closure.c
+++ b/gi/pygi-closure.c
@@ -197,7 +197,7 @@ _pygi_closure_assign_pyobj_to_out_argument (gpointer out_arg,
 }
 
 static void
-_pygi_closure_convert_ffi_arguments (PyGIInvokeState *state,
+_pygi_closure_convert_ffi_arguments (PyGIInvokeArgState *state,
                                      PyGICallableCache *cache,
                                      void **args)
 {
@@ -207,52 +207,52 @@ _pygi_closure_convert_ffi_arguments (PyGIInvokeState *state,
         PyGIArgCache *arg_cache = g_ptr_array_index (cache->args_cache, i);
 
         if (arg_cache->direction & PYGI_DIRECTION_FROM_PYTHON) {
-            state->arg_values[i].v_pointer = * (gpointer *) args[i];
-            
-            if (state->arg_values[i].v_pointer == NULL)
+            state[i].arg_value.v_pointer = * (gpointer *) args[i];
+
+            if (state[i].arg_value.v_pointer == NULL)
                 continue;
 
-            state->arg_pointers[i].v_pointer = state->arg_values[i].v_pointer;
-            state->arg_values[i] = *(GIArgument *) state->arg_values[i].v_pointer;
+            state[i].arg_pointer.v_pointer = state[i].arg_value.v_pointer;
+            state[i].arg_value = *(GIArgument *) state[i].arg_value.v_pointer;
             continue;
         }
 
         switch (arg_cache->type_tag) {
             case GI_TYPE_TAG_BOOLEAN:
-                state->arg_values[i].v_boolean = * (gboolean *) args[i];
+                state[i].arg_value.v_boolean = * (gboolean *) args[i];
                 break;
             case GI_TYPE_TAG_INT8:
-                state->arg_values[i].v_int8 = * (gint8 *) args[i];
+                state[i].arg_value.v_int8 = * (gint8 *) args[i];
                 break;
             case GI_TYPE_TAG_UINT8:
-                state->arg_values[i].v_uint8 = * (guint8 *) args[i];
+                state[i].arg_value.v_uint8 = * (guint8 *) args[i];
                 break;
             case GI_TYPE_TAG_INT16:
-                state->arg_values[i].v_int16 = * (gint16 *) args[i];
+                state[i].arg_value.v_int16 = * (gint16 *) args[i];
                 break;
             case GI_TYPE_TAG_UINT16:
-                state->arg_values[i].v_uint16 = * (guint16 *) args[i];
+                state[i].arg_value.v_uint16 = * (guint16 *) args[i];
                 break;
             case GI_TYPE_TAG_INT32:
-                state->arg_values[i].v_int32 = * (gint32 *) args[i];
+                state[i].arg_value.v_int32 = * (gint32 *) args[i];
                 break;
             case GI_TYPE_TAG_UINT32:
-                state->arg_values[i].v_uint32 = * (guint32 *) args[i];
+                state[i].arg_value.v_uint32 = * (guint32 *) args[i];
                 break;
             case GI_TYPE_TAG_INT64:
-                state->arg_values[i].v_int64 = * (glong *) args[i];
+                state[i].arg_value.v_int64 = * (glong *) args[i];
                 break;
             case GI_TYPE_TAG_UINT64:
-                state->arg_values[i].v_uint64 = * (glong *) args[i];
+                state[i].arg_value.v_uint64 = * (glong *) args[i];
                 break;
             case GI_TYPE_TAG_FLOAT:
-                state->arg_values[i].v_float = * (gfloat *) args[i];
+                state[i].arg_value.v_float = * (gfloat *) args[i];
                 break;
             case GI_TYPE_TAG_DOUBLE:
-                state->arg_values[i].v_double = * (gdouble *) args[i];
+                state[i].arg_value.v_double = * (gdouble *) args[i];
                 break;
             case GI_TYPE_TAG_UTF8:
-                state->arg_values[i].v_string = * (gchar **) args[i];
+                state[i].arg_value.v_string = * (gchar **) args[i];
                 break;
             case GI_TYPE_TAG_INTERFACE:
             {
@@ -263,11 +263,11 @@ _pygi_closure_convert_ffi_arguments (PyGIInvokeState *state,
                 interface_type = g_base_info_get_type (interface);
 
                 if (interface_type == GI_INFO_TYPE_ENUM) {
-                    state->arg_values[i].v_int = * (gint *) args[i];
+                    state[i].arg_value.v_int = * (gint *) args[i];
                 } else if (interface_type == GI_INFO_TYPE_FLAGS) {
-                    state->arg_values[i].v_uint = * (guint *) args[i];
+                    state[i].arg_value.v_uint = * (guint *) args[i];
                 } else {
-                    state->arg_values[i].v_pointer = * (gpointer *) args[i];
+                    state[i].arg_value.v_pointer = * (gpointer *) args[i];
                 }
                 break;
             }
@@ -277,19 +277,19 @@ _pygi_closure_convert_ffi_arguments (PyGIInvokeState *state,
             case GI_TYPE_TAG_GSLIST:
             case GI_TYPE_TAG_ARRAY:
             case GI_TYPE_TAG_VOID:
-                state->arg_values[i].v_pointer = * (gpointer *) args[i];
+                state[i].arg_value.v_pointer = * (gpointer *) args[i];
                 break;
             default:
                 g_warning ("Unhandled type tag %s",
                            g_type_tag_to_string (arg_cache->type_tag));
-                state->arg_values[i].v_pointer = 0;
+                state[i].arg_value.v_pointer = 0;
         }
     }
 
     if (cache->throws) {
         gssize error_index = _pygi_callable_cache_args_len (cache);
 
-        state->arg_values[error_index].v_pointer = * (gpointer *) args[error_index];
+        state[error_index].arg_value.v_pointer = * (gpointer *) args[error_index];
     }
 }
 
@@ -317,35 +317,22 @@ _invoke_state_init_from_cache (PyGIInvokeState *state,
     state->args = NULL;
     state->error = NULL;
 
-    state->args_cleanup_data = g_slice_alloc0 (state->n_args * sizeof (gpointer));
-    if (state->args_cleanup_data == NULL && state->n_args != 0) {
+    state->args = g_slice_alloc0 (state->n_args * sizeof (PyGIInvokeArgState));
+    if (state->args == NULL && state->n_args != 0) {
         PyErr_NoMemory();
         return FALSE;
     }
 
-    state->arg_values = g_slice_alloc0 (state->n_args * sizeof (GIArgument));
-    if (state->arg_values == NULL && state->n_args != 0) {
-        PyErr_NoMemory ();
-        return FALSE;
-    }
+    state->ffi_args = NULL;
 
-    state->arg_pointers = g_slice_alloc0 (state->n_args * sizeof (GIArgument));
-    if (state->arg_pointers == NULL && state->n_args != 0) {
-        PyErr_NoMemory ();
-        return FALSE;
-    }
-
-    _pygi_closure_convert_ffi_arguments (state, cache, args);
+    _pygi_closure_convert_ffi_arguments (state->args, cache, args);
     return TRUE;
 }
 
 static void
 _invoke_state_clear (PyGIInvokeState *state)
 {
-    g_slice_free1 (state->n_args * sizeof (gpointer), state->args_cleanup_data);
-    g_slice_free1 (state->n_args * sizeof (GIArgument), state->arg_values);
-    g_slice_free1 (state->n_args * sizeof (GIArgument), state->arg_pointers);
-
+    g_slice_free1 (state->n_args * sizeof (PyGIInvokeArgState), state->args);
     Py_XDECREF (state->py_in_args);
 }
 
@@ -403,7 +390,7 @@ _pygi_closure_convert_arguments (PyGIInvokeState *state,
                 value = arg_cache->to_py_marshaller (state,
                                                      cache,
                                                      arg_cache,
-                                                     &state->arg_values[i]);
+                                                     &state->args[i].arg_value);
 
                 if (value == NULL) {
                     pygi_marshal_cleanup_args_to_py_parameter_fail (state,
@@ -446,7 +433,7 @@ _pygi_closure_set_out_arguments (PyGIInvokeState *state,
                                                            cache->return_cache,
                                                            item,
                                                            &state->return_arg,
-                                                           &state->args_cleanup_data[0]);
+                                                           &state->args[0].arg_cleanup_data);
 
         if (!success) {
             pygi_marshal_cleanup_args_return_fail (state,
@@ -466,7 +453,7 @@ _pygi_closure_set_out_arguments (PyGIInvokeState *state,
             PyObject *item = py_retval;
 
             if (arg_cache->type_tag == GI_TYPE_TAG_ERROR) {
-                * (GError **) state->arg_pointers[i].v_pointer = NULL;
+                * (GError **) state->args[i].arg_pointer.v_pointer = NULL;
                 continue;
             }
 
@@ -483,8 +470,8 @@ _pygi_closure_set_out_arguments (PyGIInvokeState *state,
                                                      cache,
                                                      arg_cache,
                                                      item,
-                                                     &state->arg_values[i],
-                                                     &state->args_cleanup_data[i_py_retval]);
+                                                     &state->args[i].arg_value,
+                                                     &state->args[i_py_retval].arg_cleanup_data);
 
             if (!success) {
                 pygi_marshal_cleanup_args_to_py_parameter_fail (state,
@@ -493,8 +480,8 @@ _pygi_closure_set_out_arguments (PyGIInvokeState *state,
                 return FALSE;
             }
 
-            _pygi_closure_assign_pyobj_to_out_argument (state->arg_pointers[i].v_pointer,
-                                                        &state->arg_values[i], arg_cache);
+            _pygi_closure_assign_pyobj_to_out_argument (state->args[i].arg_pointer.v_pointer,
+                                                        &state->args[i].arg_value, arg_cache);
 
             i_py_retval++;
         }
@@ -520,14 +507,14 @@ _pygi_closure_clear_retvals (PyGIInvokeState *state,
         PyGIArgCache *arg_cache = g_ptr_array_index (cache->args_cache, i);
 
         if (arg_cache->direction & PYGI_DIRECTION_FROM_PYTHON) {
-            _pygi_closure_assign_pyobj_to_out_argument (state->arg_pointers[i].v_pointer,
+            _pygi_closure_assign_pyobj_to_out_argument (state->args[i].arg_pointer.v_pointer,
                                                         &arg, arg_cache);
         }
     }
 
     if (cache->throws) {
         gssize error_index = state->n_args - 1;
-        GError **error = (GError **) state->arg_values[error_index].v_pointer;
+        GError **error = (GError **) state->args[error_index].arg_value.v_pointer;
 
         if (error != NULL) {
             pygi_gerror_exception_check (error);
@@ -763,7 +750,7 @@ _pygi_marshal_from_py_interface_callback (PyGIInvokeState   *state,
      * The return trip to python will marshal this back and pull the python user data out.
      */
     if (user_data_cache != NULL) {
-        state->arg_values[user_data_cache->c_arg_index].v_pointer = closure;
+        state->args[user_data_cache->c_arg_index].arg_value.v_pointer = closure;
     }
 
     /* Setup a GDestroyNotify callback if this method supports it along with
@@ -779,7 +766,7 @@ _pygi_marshal_from_py_interface_callback (PyGIInvokeState   *state,
 
     if (destroy_cache) {
         if (user_data_cache != NULL) {
-            state->arg_values[destroy_cache->c_arg_index].v_pointer = _pygi_invoke_closure_free;
+            state->args[destroy_cache->c_arg_index].arg_value.v_pointer = _pygi_invoke_closure_free;
         } else {
             char *full_name = pygi_callable_cache_get_full_name (callable_cache);
             gchar *msg = g_strdup_printf("Callables passed to %s will leak references because "
@@ -793,7 +780,7 @@ _pygi_marshal_from_py_interface_callback (PyGIInvokeState   *state,
                 return FALSE;
             }
             g_free(msg);
-            state->arg_values[destroy_cache->c_arg_index].v_pointer = _pygi_destroy_notify_dummy;
+            state->args[destroy_cache->c_arg_index].arg_value.v_pointer = _pygi_destroy_notify_dummy;
         }
     }
 
@@ -819,10 +806,10 @@ _pygi_marshal_to_py_interface_callback (PyGIInvokeState   *state,
     destroy_notify_index = callback_cache->destroy_notify_index;
 
     if (user_data_index != -1)
-        user_data = state->arg_values[user_data_index].v_pointer;
+        user_data = state->args[user_data_index].arg_value.v_pointer;
 
     if (destroy_notify_index != -1)
-        destroy_notify = state->arg_values[destroy_notify_index].v_pointer;
+        destroy_notify = state->args[destroy_notify_index].arg_value.v_pointer;
 
     return _pygi_ccallback_new (arg->v_pointer,
                                 user_data,
diff --git a/gi/pygi-invoke-state-struct.h b/gi/pygi-invoke-state-struct.h
index 732f3b6..64711cb 100644
--- a/gi/pygi-invoke-state-struct.h
+++ b/gi/pygi-invoke-state-struct.h
@@ -7,6 +7,22 @@
 
 G_BEGIN_DECLS
 
+typedef struct _PyGIInvokeArgState
+{
+    /* Holds memory for the C value of arguments marshaled "to" or "from" Python. */
+    GIArgument arg_value;
+
+    /* Holds pointers to values in arg_values or a caller allocated chunk of
+     * memory via arg_pointer.v_pointer.
+     */
+    GIArgument arg_pointer;
+
+    /* Holds from_py marshaler cleanup data. */
+    gpointer arg_cleanup_data;
+
+} PyGIInvokeArgState;
+
+
 typedef struct _PyGIInvokeState
 {
     PyObject *py_in_args;
@@ -19,23 +35,13 @@ typedef struct _PyGIInvokeState
 
     /* List of arguments passed to ffi. Elements can point directly to values held in
      * arg_values for "in/from Python" or indirectly via arg_pointers for
-     * "out/inout/to Python". In the latter case, the arg_pointers[x]->v_pointer
+     * "out/inout/to Python". In the latter case, the args[x].arg_pointer.v_pointer
      * member points to memory for the value storage.
      */
-    GIArgument **args;
-
-    /* Holds memory for the C value of arguments marshaled "to" or "from" Python. */
-    GIArgument *arg_values;
+    GIArgument **ffi_args;
 
-    /* Holds pointers to values in arg_values or a caller allocated chunk of
-     * memory via arg_pointers[x].v_pointer.
-     */
-    GIArgument *arg_pointers;
-
-    /* Array of pointers allocated to the same length as args which holds from_py
-     * marshaler cleanup data.
-     */
-    gpointer *args_cleanup_data;
+    /* Array of size n_args containing per argument state */
+    PyGIInvokeArgState *args;
 
     /* Memory to receive the result of the C ffi function call. */
     GIArgument return_arg;
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index 1460280..af4d7c0 100644
--- a/gi/pygi-invoke.c
+++ b/gi/pygi-invoke.c
@@ -245,37 +245,21 @@ _invoke_state_init_from_cache (PyGIInvokeState *state,
     }
     state->n_py_in_args = PyTuple_Size (state->py_in_args);
 
-    state->args = g_slice_alloc0 (state->n_args * sizeof (GIArgument *));
+    state->args = g_slice_alloc0 (state->n_args * (sizeof (PyGIInvokeArgState) + sizeof (GIArgument *)));
     if (state->args == NULL && state->n_args != 0) {
         PyErr_NoMemory();
         return FALSE;
     }
 
-    state->args_cleanup_data = g_slice_alloc0 (state->n_args * sizeof (gpointer));
-    if (state->args_cleanup_data == NULL && state->n_args != 0) {
-        PyErr_NoMemory();
-        return FALSE;
-    }
-
-    state->arg_values = g_slice_alloc0 (state->n_args * sizeof(GIArgument));
-    if (state->arg_values == NULL && state->n_args != 0) {
-        PyErr_NoMemory ();
-        return FALSE;
-    }
-
-    state->arg_pointers = g_slice_alloc0 (state->n_args * sizeof(GIArgument));
-    if (state->arg_pointers == NULL && state->n_args != 0) {
-        PyErr_NoMemory ();
-        return FALSE;
-    }
+    state->ffi_args = (gpointer)((char*)state->args + state->n_args * sizeof (PyGIInvokeArgState));
 
     state->error = NULL;
 
     if (cache->throws) {
         gssize error_index = state->n_args - 1;
         /* The ffi argument for GError needs to be a triple pointer. */
-        state->arg_pointers[error_index].v_pointer = &state->error;
-        state->args[error_index] = &(state->arg_pointers[error_index]);
+        state->args[error_index].arg_pointer.v_pointer = &state->error;
+        state->ffi_args[error_index] = &(state->args[error_index].arg_pointer);
     }
 
     return TRUE;
@@ -284,11 +268,7 @@ _invoke_state_init_from_cache (PyGIInvokeState *state,
 static void
 _invoke_state_clear (PyGIInvokeState *state, PyGIFunctionCache *function_cache)
 {
-    g_slice_free1 (state->n_args * sizeof(GIArgument *), state->args);
-    g_slice_free1 (state->n_args * sizeof(gpointer), state->args_cleanup_data);
-    g_slice_free1 (state->n_args * sizeof(GIArgument), state->arg_values);
-    g_slice_free1 (state->n_args * sizeof(GIArgument), state->arg_pointers);
-
+    g_slice_free1 (state->n_args * (sizeof (PyGIInvokeArgState) + sizeof (GIArgument *)), state->args);
     Py_XDECREF (state->py_in_args);
 }
 
@@ -381,17 +361,17 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGIFunctionCache *function_cac
     }
 
     for (i = 0; i < _pygi_callable_cache_args_len (cache); i++) {
-        GIArgument *c_arg = &state->arg_values[i];
+        GIArgument *c_arg = &state->args[i].arg_value;
         PyGIArgCache *arg_cache = g_ptr_array_index (cache->args_cache, i);
         PyObject *py_arg = NULL;
 
         switch (arg_cache->direction) {
             case PYGI_DIRECTION_FROM_PYTHON:
                 /* The ffi argument points directly at memory in arg_values. */
-                state->args[i] = c_arg;
+                state->ffi_args[i] = c_arg;
 
                 if (arg_cache->meta_type == PYGI_META_ARG_TYPE_CLOSURE) {
-                    state->args[i]->v_pointer = state->user_data;
+                    state->ffi_args[i]->v_pointer = state->user_data;
                     continue;
                 } else if (arg_cache->meta_type != PYGI_META_ARG_TYPE_PARENT)
                     continue;
@@ -448,7 +428,7 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGIFunctionCache *function_cac
                  * (_invoke_marshal_out_args) can always rely on arg_pointers pointing to
                  * the correct chunk of memory to marshal.
                  */
-                state->arg_pointers[i].v_pointer = c_arg;
+                state->args[i].arg_pointer.v_pointer = c_arg;
 
                 if (arg_cache->is_caller_allocates) {
                     /* In the case of caller allocated out args, we don't use
@@ -457,7 +437,7 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGIFunctionCache *function_cac
                      * above, arg_pointers will also point to this caller allocated
                      * chunk of memory used by out argument marshaling.
                      */
-                    state->args[i] = c_arg;
+                    state->ffi_args[i] = c_arg;
 
                     if (!_caller_alloc (arg_cache, c_arg)) {
                         char *full_name = pygi_callable_cache_get_full_name (cache);
@@ -473,7 +453,7 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGIFunctionCache *function_cac
                 } else {
                     /* Non-caller allocated out args will use arg_pointers as an
                      * extra level of indirection */
-                    state->args[i] = &state->arg_pointers[i];
+                    state->ffi_args[i] = &state->args[i].arg_pointer;
                 }
 
                 break;
@@ -502,7 +482,7 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGIFunctionCache *function_cac
                                                      py_arg,
                                                      c_arg,
                                                      &cleanup_data);
-            state->args_cleanup_data[i] = cleanup_data;
+            state->args[i].arg_cleanup_data = cleanup_data;
 
             if (!success) {
                 pygi_marshal_cleanup_args_from_py_parameter_fail (state,
@@ -579,7 +559,7 @@ _invoke_marshal_out_args (PyGIInvokeState *state, PyGIFunctionCache *function_ca
         py_out = arg_cache->to_py_marshaller (state,
                                               cache,
                                               arg_cache,
-                                              state->arg_pointers[arg_cache->c_arg_index].v_pointer);
+                                              state->args[arg_cache->c_arg_index].arg_pointer.v_pointer);
         if (py_out == NULL) {
             pygi_marshal_cleanup_args_to_py_parameter_fail (state,
                                                             cache,
@@ -602,7 +582,7 @@ _invoke_marshal_out_args (PyGIInvokeState *state, PyGIFunctionCache *function_ca
             PyObject *py_obj = arg_cache->to_py_marshaller (state,
                                                             cache,
                                                             arg_cache,
-                                                            
state->arg_pointers[arg_cache->c_arg_index].v_pointer);
+                                                            
state->args[arg_cache->c_arg_index].arg_pointer.v_pointer);
 
             if (py_obj == NULL) {
                 if (has_return)
@@ -644,7 +624,7 @@ pygi_invoke_c_callable (PyGIFunctionCache *function_cache,
         ffi_call (&function_cache->invoker.cif,
                   state->function_ptr,
                   (void *) &ffi_return_value,
-                  (void **) state->args);
+                  (void **) state->ffi_args);
 
     Py_END_ALLOW_THREADS;
 
diff --git a/gi/pygi-marshal-cleanup.c b/gi/pygi-marshal-cleanup.c
index b0ec05a..b2e91eb 100644
--- a/gi/pygi-marshal-cleanup.c
+++ b/gi/pygi-marshal-cleanup.c
@@ -95,7 +95,7 @@ pygi_marshal_cleanup_args_from_py_marshal_success (PyGIInvokeState   *state,
     for (i = 0; i < _pygi_callable_cache_args_len (cache); i++) {
         PyGIArgCache *arg_cache = _pygi_callable_cache_get_arg (cache, i);
         PyGIMarshalCleanupFunc cleanup_func = arg_cache->from_py_cleanup;
-        gpointer cleanup_data = state->args_cleanup_data[i];
+        gpointer cleanup_data = state->args[i].arg_cleanup_data;
 
         /* Only cleanup using args_cleanup_data when available.
          * It is the responsibility of the various "from_py" marshalers to return
@@ -107,7 +107,7 @@ pygi_marshal_cleanup_args_from_py_marshal_success (PyGIInvokeState   *state,
                 arg_cache->direction & PYGI_DIRECTION_FROM_PYTHON) {
             PyObject *py_arg = PyTuple_GET_ITEM (state->py_in_args, arg_cache->py_arg_index);
             cleanup_func (state, arg_cache, py_arg, cleanup_data, TRUE);
-            state->args_cleanup_data[i] = NULL;
+            state->args[i].arg_cleanup_data = NULL;
         }
     }
 }
@@ -133,7 +133,7 @@ pygi_marshal_cleanup_args_to_py_marshal_success (PyGIInvokeState   *state,
     while (cache_item) {
         PyGIArgCache *arg_cache = (PyGIArgCache *) cache_item->data;
         PyGIMarshalCleanupFunc cleanup_func = arg_cache->to_py_cleanup;
-        gpointer data = state->arg_values[arg_cache->c_arg_index].v_pointer;
+        gpointer data = state->args[arg_cache->c_arg_index].arg_value.v_pointer;
 
         if (cleanup_func != NULL && data != NULL)
             cleanup_func (state,
@@ -165,7 +165,7 @@ pygi_marshal_cleanup_args_from_py_parameter_fail (PyGIInvokeState   *state,
     for (i = 0; i < _pygi_callable_cache_args_len (cache)  && i <= failed_arg_index; i++) {
         PyGIArgCache *arg_cache = _pygi_callable_cache_get_arg (cache, i);
         PyGIMarshalCleanupFunc cleanup_func = arg_cache->from_py_cleanup;
-        gpointer cleanup_data = state->args_cleanup_data[i];
+        gpointer cleanup_data = state->args[i].arg_cleanup_data;
         PyObject *py_arg = NULL;
 
         if (arg_cache->py_arg_index < 0) {
@@ -188,7 +188,7 @@ pygi_marshal_cleanup_args_from_py_parameter_fail (PyGIInvokeState   *state,
                                        cleanup_data,
                                        FALSE);
         }
-        state->args_cleanup_data[i] = NULL;
+        state->args[i].arg_cleanup_data = NULL;
     }
 }
 


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