lua-users home
lua-l archive

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


>> There's a way to attach a pointer (possibly pointing to structure of
>> several things you will actually use) to lua_State
>> by passing it to lua_newstate () or by setting it with lua_setallocf ().
>
> Actually I think the correct method for this is to set LUAI_EXTRASPACE in
> luaconf.h

Thanks for information: I've missed that
But that's different by 2 aspects:
1. It is build-time feature. Though in my current project that's
irrelevant - I don't use liblua.so
2. The feature is per-coroutine rather than per global_State.
So using LUAI_EXTRASPACE would lead to unnecessary allocations and
access to main thread's state like ((void*) (G(L)->mainthread) -
sizeof (void*)).
Looks like Spartaaaaaa!!!!!!!!!!111...

I will use 'lua_getallocf ()' for now or simply write lua_getallocud
() for myself.
But I think lua_getallocud () is good for API in general.