[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: crash in Lua 5.1 and 5.2: calling C function from unloaded lib
- From: Alexander Gladysh <agladysh@...>
- Date: Mon, 9 Apr 2012 11:10:37 +0400
> if _VERSION >= 'Lua 5.2' then
> function atexit(fn)
> setmetatable({}, { __gc = fn })
> end
> else
> function atexit(fn)
> getmetatable(newproxy(true)).__gc = fn
> end
Note that this is not a good atexit() function — it would be called at
the next full GC cycle.
You have to store the object somewhere.
Alexander.