[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Memory allocation of arrays
- From: Duncan Cross <duncan.cross@...>
- Date: Fri, 21 Jul 2017 13:37:43 +0100
On Fri, Jul 21, 2017 at 12:21 PM, Rodrigo Azevedo <rodrigoams@gmail.com> wrote:
> Then, this seems to be an "implementation detail" that I would want to avoid.
>
> Is this possible? How?
The C API has a lua_createtable() function [1] allows you to specify
the size of the array part on table creation using the "narr"
parameter. This functionality isn't normally exposed to the Lua side,
and it does mean you have to know the exact length you want before you
begin populating the table, but if those are not problems for you then
this looks like your best opportunity.
[1] https://www.lua.org/manual/5.3/manual.html#lua_createtable
-Duncan