lua-users home
lua-l archive

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

Hi Pierre

For example, while binding a GUI library, a button can have an image
attached. The image and the button are userdata type, both created in
lua (via the C API), but the image is linked to the button also via the
C API. so, lua has no way to know that the image cannot be freed because
linked to another object outside of its control.
I think you should create a reference to the image userdata and store it in the button userdata. When the button is freed Lua will call the button _gc and then you'll have to release the reference to the image.

How can I tell lua the resource is being used and then no more used
(block from gc or ready for gc)?
Check luaL_ref and luaL_unref.