[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: cleanup in a C module
- From: Mailing-Listen <list@...>
- Date: Wed, 23 Jun 2010 21:31:21 +0200
On Wed, Jun 23, 2010 at 10:17:16PM +0300, M Joonas Pihlaja wrote:
> > Then I wanted to compile the language binding as a module. That works fine as
> > long as it runs. But I have the problem, that I don't know how to do the
> > cleanup afterwards.
> When your module is opened for the first time you can store a userdata
> in the registry and set the userdata's __gc metamethod to do whatever
> cleanup you need. When the lua_State is being destroyed your cleanup
> function will be executed before your module is unloaded by Lua.
That sounds like it is what I was looking for. I admit that I am not
that deep into lua, yet. But I'm definitely going to have a look at it.