[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: stack/memory problem
- From: Patrick Rapin <toupie300@...>
- Date: Wed, 14 Dec 2011 13:43:24 +0100
> How is proper stack handling supposed to be done?
I don't think there is an official way to handle stack.
You can, as Peter Pimley points out, remove all elements from the
stack ( i.e. lua_settop(L, 0) ) after calling lua_pcall.
What my library LuaClassBasedCall does is to call lua_settop *at the
start of* the calling process.
By the way, using LuaClassBasedCall prevents the programmer from a lot
of API misuses, like stack overflows...
Schematically, the library always performs these 5 operations :
1) lua_settop(L,0)
2) compile snippet to stack (or take from cache)
3) push input arguments to stack
4) lua_call
5) retrieve results from stack