[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: using light userdata to keep full userdata alive?
- From: "Wesley Smith" <wesley.hoke@...>
- Date: Tue, 8 Jan 2008 14:43:01 -0800
> AFAIK the only way to handle your situation is to pass around the full
> big userdata (which is handle by reference, so it's just a pointer
> passed around), or eventually a smaller (but still full) userdata which
> contains only the array pointer. In that case you have to link the big
> and small (full) userdatas in some way (with a weak table or the
> metatable/environment mechanisms).
I use Boost's intrusive_ptrs for this problem and handle it fully
within C++ since I want the behavior to work even without Lua. But,
it also works together with Lua automatically as long as you properly
define the __gc method to not delete but let intrusive_ptrs do it.