Date: Thu, 08 Sep 2005 10:57:13 +0900 (JST) Message-Id: <20050908.105713.102767324.garrigue at math.nagoya-u.ac.jp> To: andrieu at ijm.jussieu.fr Cc: romildo at uber.com.br, lablgtk at math.nagoya-u.ac.jp Subject: Re: Help in C interface From: Jacques Garrigue In-Reply-To: <17183.24114.533709.114006 at karryall.dnsalias.org> References: <20050907192141.GA7177 at malaquias> <17183.24114.533709.114006@karryall.dnsalias.org> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit From: Olivier Andrieu > You can use g_object_set_data_full() to tie your dynamically allocated > arrays to the object. This function lets you register a finalizer > function that will free the arrays when the GtkDatabox object is > finalized. Somthg like this: Wouldn't it be simpler to register a callback on destroy? Since a GtkDatabox inherit from GtkObject, it has a destroy signal. This avoids adding a "key" parameter, whose role seems unclear here. You can also pack the two arrays in one, to use only one allocation. So you could write: const gint n = Int_val(length); gfloat *vetx = g_new(gfloat, 2 * n); gfloat *vety = vetx+n; g_signal_connect_swapped(G_OBJECT(box), "destroy", G_CALLBACK(g_free), vetx); This should be enough in practice. Also, the cost of copying the data is so small that there should be no problem in the conversion approach you use. Bigarrays are interesting only when the data is huge, or shared with C in a complex way. Jacques