|
On 15/01/2013 4:22 PM, Hadriel Kaplan wrote:
For example, if you use luaL_ref() with the Registry to provide a unique reference to a created userdata to avoid creating multiples, by storing that reference integer in the C++ object, then you can use that instead of the raw userdata address to find it again from the Registry. The C++ object's destructor would use it to find the userdata from the Registry, clear its own pointer from within the userdata, and remove the reference from the Registry (luaL_unref). It sounds like that might work(?)
I could be wrong but I think this involves a hash table lookup every time you want to construct or invalidate a pointer. That's a valid approach but it's nowhere near as as efficient as the counter method we started with.
Ross.