lua-users home
lua-l archive

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


> I can't seem to find any information regarding ownership when using 
> the lua_pushusertag C function.

Lua "owns" the pointer itself, but has no interaction at all with the 
object pointed to. Lua never references the pointer, does not 
garbage-collect it, nor uses it in any way. In fact, the "pointer" does not 
need to be a valid pointer at all; you can call 
«lua_pushuserdata((void *)3)» without any problem. 

If the userdata has a garbage-collection tag method, this method is called 
when the pointer itself is being "released" by Lua, that is, Lua is 
assuring you that it does not have a copy of that pointer value anymore. It 
is up to you to free your object when this tag method is called. 

-- Roberto