lua-users home
lua-l archive

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


On 01/21/2011 08:06 PM, Mike Pall wrote:
LuaJIT Roadmap 2011
-------------------

Wow, this is such cool stuff :)

I've got a question about the intended behaviour of VLA's, though. What's the canonical way to resize them? I don't get the "Variable Length" part of "Variable Length Array". Do we use ffi.C.realloc and friends, or is it smarter than that?

The following segfaults on my box:

local ffi = require("ffi")
ffi.cdef[[
   int sprintf(char *str, const char *format, ...);
]]

local buf = ffi.new("char[?]", 16)
ffi.C.sprintf(buf, "%s", string.rep("x", 17)) -- buffer overflow?
print(ffi.string(buf));

Grateful for any pointers (excuse the pun).

Thanks,
Richard