[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: gc problem when using lightuserdata to reference C++ objects
- From: "Markus Heukelom" <Markus.Heukelom@...>
- Date: Fri, 14 Nov 2008 17:27:32 +0100
> To do that you need to make sure any allocated object is
> allocated with lua_newuserdata. In C that is easy, you can
> create a malloc/free interface around that function. In C++
> this is slightly more tricky since you need to override the
> new operator.
Overloading new is not necessary, just use placement new:
class A {...}
void *p = lua_newuserdata(sizeof(A));
A *a = new(p) A;
Markus