[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Reusing tables from C
- From: liam mail <liam.list@...>
- Date: Fri, 16 Sep 2011 11:32:28 +0100
On 16 September 2011 11:28, Peter Pimley <email@example.com> wrote:
> Could you create the table and put it in the registry before the loop?
> On 16 September 2011 11:21, Antonio Vieiro <firstname.lastname@example.org> wrote:
>> Hi all,
>> I'm invoking a Lua function from C within a loop, and I'm passing it a
>> table as an argument.
>> I'd like to reuse the table between invocations (so on each iteration
>> of the loop I don't invoke lua_createtable again), but lua_call (or
>> lua_pcall) cleans up the stack after the call, so I have little chance
>> to reuse the table.
>> Is there a trick to do this from C?
Use lua_pushvalue so that there are two entries for the table, one of
which is used for the function and the other remains on the stack.