GArray** as return value - howto to free from python?



Hi,

i use gobject introspection for a library [1] to simulate renewable
energy systems.

I have a function with this prototype (see [2]):

void 
isas_pv_module_characteristic_curve(gint U_steps, gdouble U_startvalue,
gdouble border_difference, gdouble m1, gdouble m2, gdouble U_T, gdouble
I_Ph, gdouble I_S1, gdouble I_S2, gdouble R_S, gdouble R_P, GArray**
res_U, GArray** res_I);

The GArray's res_U and res_I are created with:
*res_U = g_array_new(FALSE, FALSE, sizeof(gdouble));
*res_I = g_array_new(FALSE, FALSE, sizeof(gdouble));

I can use the function from python with:
$ python
Python 2.6.6 (r266:84292, Apr 20 2011, 11:58:30) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import Isas, GLib
>>> res_u, res_i =
Isas.pv_module_characteristic_curve(100,1,0.0001,1,2,10,1,2,3,1,2)
>>>

The values of res_u and res_i are avaialble.

My question is, how i can free the GArray's from python? 

I tried GLib.array_free(), but:

>>> GLib.array_free(res_u, False)
*** glibc detected *** python: free(): invalid pointer: 0x08719390 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6(+0x6aaa1)[0xb73eeaa1]
/lib/i686/cmov/libc.so.6(+0x6c308)[0xb73f0308]
/lib/i686/cmov/libc.so.6(cfree+0x6d)[0xb73f33bd]
/lib/libglib-2.0.so.0(g_free+0x36)[0xb6fc73a6]
/lib/libglib-2.0.so.0(g_array_free+0x8f)[0xb6f9234f]
/usr/lib/python2.6/dist-packages/gi/_gi.so(+0xdcb3)[0xb7102cb3]



Cheers,

Tom




[1] https://gitorious.org/isas
[2]
https://gitorious.org/isas/isas/blobs/master/libisas/isas-pv.c#line357

Attachment: signature.asc
Description: This is a digitally signed message part



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