lua-users home
lua-l archive

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


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.