Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails SOLVED

  • From: Adam Strzelecki <ono@xxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 21 Jun 2012 12:23:37 +0200

> local buf = ffi.new("char[?]", 0, "HELLO WORLD")  does the trick

This makes me wonder if it doesn't write out of allocated memory range? AFAIK 
FFI does not check for memory ranges, so it doesn't crash, but it may at any 
time, or I am missing sthing (!?).

Anyway putting "Hello World" in your code instances a Lua string already, so I 
don't think putting it into local str variable makes any difference.

Cheers,
-- 
Adam Strzelecki | nanoant.com | twitter.com/nanoant


Other related posts: