[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to pass arguments to argv function effectively in Lua C API
- From: Alexander Gladysh <agladysh@...>
- Date: Thu, 24 Mar 2011 19:35:23 +0300
On Thu, Mar 24, 2011 at 15:26, Tony Finch <dot@dotat.at> wrote:
> Tony Finch <dot@dotat.at> wrote:
>> /* lay out all the arrays within a userdata object */
>> args = lua_newuserdata(L, total);
>> argv = (void *)(args + args_size);
>> argl = (void *)(args + args_size + argv_size);
> Er, sorry, that can screw up the alignment restrictions.
> Try this instead:
> args = lua_newuserdata(L, total);
> argv = (void *)args; args += argv_size;
> argl = (void *)args; args += argl_size;
Thank you!
I think that I will stick to Luiz suggestion with keeping limited size
arrays on stack, but your solution sure beats what I wrote, and if I
will need to allocate arrays dynamically, I'll use it.
Alexander.