lua-users home
lua-l archive

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


> Before a lua object collected, the result of lua_topointer is never
> changed. Am I right?

Yes.

> Can you guarantee this will not be changed in future version of lua ?

No, but we have no plans for a moving garbage collector.

> I have another question.
> When I use lua_newuserdata(or lua_touserdata) to get a pointer to the
> memory , can I save it in my C struct directly? or I should use
> lua_tousedata to convert the userdata to a pointer every time I need ?

If you can guarantee that the memory is not collected, then yes you can
store the pointer. But remember that memory allocated via lua_newuserdata
is subject to garbage collection.
--lhf