lua-users home
lua-l archive

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


> > However, is this restriction strictly true if I can guarantee - from
> > my code flow - that the original string in lua will continue to be in
> > reachable (that is, it is not garbage collected) when my C function
> > call returns?
> 
> AFAIK, yes, as long as you can guarantee that the string is anchored.

Strictly speaking, you cannot assume that the address of the internal
string does not change after garbage collection because Lua might use
a moving garbage collector. The standard implementation from lua.org
does not move data and there are no plans for changing this. Other
implementations of Lua may differ, but AFAIK they don't.