[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: tolua, delete(), and garbage collection
- From: Christian Vogler <cvogler@...>
- Date: Sun, 21 Oct 2001 00:39:19 -0400
On Sat, Oct 20, 2001 at 11:28:25PM -0500, Fabian Lemke wrote:
> CPoint GetPos();
> If, in lua, I do the following:
> pos = GetPos()
> ..[do stuff]..
> then it works fine, but with no "delete", it bombs.
Is CPoint a class or struct that is defined in the *.pkg file? My
suspicion is that the explicit call to delete() works because of
happenstance, not because it is correct.
Are you using plain C or C++? A very important rule for tolua pkg
files is that for C++ bindings you always must declare the destructor,
even if it is generated implictly for you by the compiler. Otherwise,
tolua will mistakenly call free() on an object that should be freed up
with C++'s delete operator.
It is difficult to say what exactly is happening without more
information. Could you possibly provide the *.pkg snippet for the
CPoint struct/class and the GetPos() function, and also tell us
whether the bindings are to C or C++?