[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: cleanup in a C module
 
- From: M Joonas Pihlaja <jpihlaja@...>
 
- Date: Wed, 23 Jun 2010 22:17:16 +0300 (EEST)
 
> 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.
Joonas