Hi Nicolas

In the code below I'm using alloc_root to save the object and function
to call on a gtk callback. You'll notice the absense of free_root(),
that's because gtk_signal_connect is a first time connection and can be
called many times, so i don't want to free the neko callback data on
the first event.

So, the question is, I need to store the alloc_root pointer, and the
best place to do so would be back in the object that's firing the
event, then I can free the alloc_root data when the object is finalised.

So is it ok to wrap alloc_root pointer as an abstract and store it back
in the original object?

The problem is that since your store your widget in your root, it will never get GC'ed. You should consider alloc'ating a structure that contains a list of connected events and store this list in your widget abstract data. If the abstract data + the list is allocated with alloc(), everything will be correctly GC'ed as soon as the object is GC'ed. In general, trying to avoid as much as possible alloc_root is a good idea.

Nicolas

--
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to