lua-users home
lua-l archive

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



On 14-Oct-04, at 3:19 PM, David Jones wrote:

The official line is that this is true only whilst the lua string that is passed to lua_tostring remains on the (Lua) stack. In other words Lua reserves the right to implement a moving memory manager. Of course, all the current implementations will never move the string. So it's okay.

Well, the 5.0.2 reference manual says:

"Because Lua has garbage collection, there is no guarantee that the pointer returned by lua_tostring will be valid after the corresponding value is removed from the stack. If you need the string after the current function returns, then you should duplicate it or put it into the registry."

I assume that is what you are talking about. However, the "or put it into the registry" part seems to me to indicate that Lua doesn't reserve the right to use a moving memory manager. (Although I suppose that technically a moving memory manager could handle registries specially.)

Pending a final arbitration by the Lua team.... :)

R.