lua-users home
lua-l archive

RE: Thinking about Lua memory management

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 2001年9月20日, 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

AltStyle によって変換されたページ (->オリジナル) /