lua-users home
lua-l archive

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


> This is a newbies question: If i create multiple userdata objects,
> what the best way to find out if that userdata pointer that i get from
> the stack belongs to my "Foobar" c struct.
> 
> At the moment i'm using an hash table for all my own userdata,
> lookup the pointer there and if found i get a verification that this
> userdata is really a "Foobar" struct.

This is one way, yes. But I hope you're using a Lua table for that, not
your own hash table...

For another way, see http://www.lua.org/pil/28.html , especially section 28.2.
--lhf