[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Thinking about Lua memory management
- From: Roberto Ierusalimschy <rieru@...>
- Date: Thu, 20 Sep 2001 14:09:46 -0500 (CDT)
On Thu, 20 Sep 2001, Joshua Jensen wrote:
> > > Are you planning to move objects?
> >
> > No... Among other problems, GC can happen while C code keeps
> > pointers to strings inside Lua.
>
> I say this is too bad. They should lua_ref() the object if they want it
> to keep it. There is no guarantee the pointer in the C code will be
> good anyway, since Lua could have garbage collected it.
Maybe I was not clear. See following code:
int f (lua_State *L) {
const char *s = lua_tostring(L, 1);
lua_call(...); /* GC may occur here! */
/* now, what about `s'?? */
-- Roberto