lua-users home
lua-l archive

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

> I'm testing some code that creates and releases 500 references using
> luaL_ref and luaL_unref. Even though the calls to luaL_ref and
> luaL_unref are paired, I notice that each call to luaL_ref returns a
> number that is 1 greater than the previous reference number. I assume
> this behavior is expected but I though I'd post here to make sure. (I
> was guessing that reference numbers would be reused.)

This behavior is not expected (if I understood you correctly). As soon
as you release a reference it can be used again; luaL_ref should only
return a "new" (greater) index when there are no free (previously
unref) numbers left.

(This does not apply when the value being referenced is nil. In this
case luaL_ref always returns -1, the value of LUA_REFNIL.)

-- Roberto