[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: toLua memory-management question
- From: Waldemar Celes <celes@...>
- Date: Fri, 06 Jul 2001 15:04:09 -0300
I've got a toLua question about memory management. I have several C++
functions that allocate some memory, and return the new object to Lua via
the standard toLua bindings. Now, in some cases, I'd really like to be able
to have the right destructor for that object called when the object is
garbage collected from Lua. Other times, I prefer to pass ownership of the
object off to some other C++ class.
I've noticed functions like tolua_takeownership() but cannot figure out how
they are designed to work. Can someone give me a few suggestions? Can toLua
be configured to set the "gc" tag for objects that I want to take ownership
tolua_takeownership tells tolua to destruct the object when its corresponding
userdata is garbage collected.
so, you con takeownership only for those objects you want the destructor