lua-users home
lua-l archive

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



With Lua 5.0 you could use a simple wrapper function:

local refs = setmetatable({}, { __mode = 'k' })

function CreateFont(bmp)
  local font = gfx.CreateFont(bmp)
  refs[font] = bmp
  return font
end

- Peter Shook

Tobias Käs wrote:
Is it possible for userdata to tell the GC it has a (native) reference to another userdata object, and so prevent the GC to collect it?
Here's an example how i thought to use it: