lua-users home
lua-l archive

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


On Sep 1, 2013, at 1:51 AM, Mikhail Gusarov <dottedmag@dottedmag.net> wrote:

> Or you can declare that all lua_States in your program are inside
> LuaPrivateState, so the outer struct can be accessed by pointer
> conversion:
> 
> struct LuaPrivateState *state = (struct LuaPrivateState *)((char
> *)lua_state - offsetof(struct LuaPrivateState, pVM));
> 
> 
> Best regards,
> Mikhail Gusarov.
> 

Yep, looked at that too, but as others have noted here, the issue is with coroutines, which may expose a Lua_State that is NOT wrapped like this, and there is no way to tell from the C function if that is the case or not.

To date, using the custom allocator seems the best "trick", though I'm not totallyhappy with it.

--Tim