lua-users home
lua-l archive

Re: Modules for iconv (Was: UTF-8 patterns in Lua 5.3)

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Apr 21, 2014 at 02:22:23PM -0700, Coroutines wrote:
> On Mon, Apr 21, 2014 at 8:37 AM, Roberto Ierusalimschy
> <roberto@inf.puc-rio.br> wrote:
> >> The main benefit of using variable-length arrays is allocating on the
> >> stack, which can also be done with alloca() -- both avenues not
> >> possible with C89. Going the route of luaL_Buffer would still
> >> allocate on the heap (internally using Lua's set allocator function --
> >> which looks like realloc). [...]
> >
> > luaL_Buffer only allocates on the heap after a certain size limit
> > (typically 8 KB). Otherwise it uses the stack.
> >
> > -- Roberto
> >
> 
> The C stack or the Lua stack?
The C stack. Here's the luaL_Buffer definition:
 typedef struct luaL_Buffer {
 char *b; /* buffer address */
 size_t size; /* buffer size */
 size_t n; /* number of characters in buffer */
 lua_State *L;
 char initb[LUAL_BUFFERSIZE]; /* initial buffer */
 } luaL_Buffer;

AltStyle によって変換されたページ (->オリジナル) /