Re: Is there a way to do a stack allocation in luajit?
From: Mike Pall <mike-1302@xxxxxxxxxx>
To: luajit@xxxxxxxxxxxxx
Date: Tue, 12 Feb 2013 10:03:13 +0100
鋆邓 wrote:
> How can I avoid this malloc&free?
local cwd_buf = ffi.new("char[256]")
function path.current()
local ret = C._getcwd(cwd_buf, 256)
if ret == nil then error("path too long") end
return ffi.string(ret)
end
--Mike