[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Increasing MAXSTACK implications
- From: Patrick Rapin <toupie300@...>
- Date: Sat, 31 Dec 2011 13:59:49 +0100
> Hmm, no replies so far :/ .... is it because of the old Lua version that I'm using?
Maybe it is because people, like me, do not really understand your problem.
> I do not need to pass more than 255 arguments
> to my functions but I need to pass tables with tons of items and they
> require more stack space than 250 items.
Tables are handled by reference in Lua. Pushing a table on the stack
only takes 1 slot from it, no matter how big the table is.
So you shouldn't need such a big stack just because you pass "tables
with tons of items" to functions.
Unless you wrote something like that:
int N = lua_getn(L, 1); // N is big
lua_rawgeti(L, 1, i+1);
printf("%d: %s\n", i, lua_tostring(L, -1));
This loop will exhaust the stack if N is bigger that ~1000 ! Instead,
you have to call "lua_pop(L, 1);" after the printf function in the