[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: is it possible to set a minimum size for the stack of a lua_State?
- From: Graham Wakefield <lists@...>
- Date: Sat, 13 Jan 2007 14:36:24 -0800
Is it possible to set a minimum size for the stack of a lua_State?
I'd like to pre-allocate (I often need more than 20 elements on the
stack) and avoid gc from deallocating/reallocating this all the time.
Looked at lua_checkstack but I get error codes from it; even when
only asking for 128 new spaces on the stack.
Sample code:
Lparent = lua_open();
luaL_openlibs(Lparent);
// create the audio callback's child lua_State:
lua_pushstring(Lparent, "L"); /* push address */
L = lua_newthread(Lparent);
lua_settable(Lparent, LUA_REGISTRYINDEX); // protect from gc
// create some extra space on stack so that we don't overfill it:
if (lua_checkstack(L, 128)) error("Lua can't allocate stack
space"); ///< this error is triggered.