lua-users home
lua-l archive

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


> What exactly is the behaviour of lua_pushusertag(u,t) ?

For userdata, equality is identity.
If there is a userdata u with tag t in the Lua environment,
this same object is reused when you push it again.
That is, there is only one copy of
equal objects in the environment. If you want to do reference-count,
all you need is a boolean. When you push an object (void *) into
Lua, set the boolean to true. When Lua calls the gc fallback, set
the boolean to false: It means Lua has no more any reference to this
specific userdata.

-- Roberto