[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Reference counting
- From: Renato Cerqueira <rcerq@...>
- Date: Fri, 23 Mar 2001 17:39:28 -0600
"J. Perkins" wrote:
> Diego Nehab wrote:
>
> > When you do ref=lua_ref(L, 1), Lua reserves space in a reference vector
> > for that object, saves the object in that vector and returns an index to
> > you. When you call lua_getref(L, ref), Lua pushes the corresponding
> > index from that vector in the Lua stack. When you call lua_unref(L,
> > ref), Lua marks the position on the vector as free for further lua_ref
> > calls so that the value of ref is meaningless after the call to
> > lua_unref.
> >
> > (snip)
> >
> > Did that answer your question?
>
> Yes, that did. I guess I need to do something like:
>
> lua_getref(L, ref);
> lua_unref(L);
> ref = lua_ref(L, 0);
>
> ...to properly unlock an object then.
No, it is not true.
You just need to do:
lua_unref(L,ref);
Regards,
Renato