[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: abort a lua_newthread from C and re-use its lua_State?
- From: Shmuel Zeigerman <shmuz@...>
- Date: Mon, 30 Apr 2007 08:19:12 +0200
Graham Wakefield wrote:
Another thought - is it possible to get some kind of callback from a
lua_State when it is collected? This would allow me to free C resources
attached to it and prevent my memory leak. Something like a __gc method
for states created via lua_newthread.
Yes - create a userdata with a __gc metamethod, then put it
(the userdata) into the lua_State's registry under some unique
key (e.g., the userdata itself).