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

  • From: "Robert G. Jakabosky" <bobby@xxxxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 21 Jun 2012 03:39:46 -0700

On Thursday 21, Patrick Masotta wrote:
> local buf = ffi.new("char[?]", 0, "HELLO WORLD")  does the trick

Don't do that you are corrupting memory.  See that attached script.

-- 
Robert G. Jakabosky
local ffi = require"ffi"

local bufs = {}

for i=1,1000 do
        bufs[i] = ffi.new("char[?]", 0, "Hello, 
World!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
end

Other related posts: