lua-users home
lua-l archive

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


On Fri, Dec 16, 2011 at 4:42 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> The manual says of `luanewuserdata`:
> …allocates a new block of memory with the given size, pushes onto the
> stack a new full userdata with the block address, and returns this
> address.
>
> It does not say the block is initialized to zero, but that invariably
> has so far been true on my system.
>
> Implementation detail?

>From a quick browse of the Lua source [1], it would seem that the
initial contents is whatever your memory allocation routine puts into
newly allocated blocks.

[1]: The call chain is:
http://www.lua.org/source/5.1/lapi.c.html#lua_newuserdata
http://www.lua.org/source/5.1/lstring.c.html#luaS_newudata
http://www.lua.org/source/5.1/lmem.c.html#luaM_realloc_