lua-users home
lua-l archive

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


Hi Mike,

Attachment is a simple test program, run it like:

$ luajit test.lua 10000

In my computer, when count > 50, this test will cause luajit crash.

OS: archlinux i686
CPU:core-i7 2630QM
luajit version: HEAD master

Best,
Zhu Ya Dong
local ffi = require'ffi'
ffi.cdef[[
typedef struct rect{float left, top, right, bottom;};
]]
local rect_t = ffi.typeof('struct rect')
local function offset(r, dx, dy)
    r.left, r.top, r.right, r.bottom = 
    r.left+dx, r.top+dx, r.right+dy, r.bottom+dy
end

local r = rect_t(0,0,100,100)

local narg = select('#',...)
if narg < 1 then error('give a number as arg please.') end

local count = tonumber(select(1,...))

for i=1,count do
    offset(r, 10, 10)
    offset(r, -10, -10)
end
print('done')