lua-users home
lua-l archive

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


On 12.04.2010 at 17:25 Peter Cawley wrote:

>2010/4/12 Andreas Falkenhahn <andreas@airsoftsoftwair.de>:
>> when I use luaL_ref() on a string that is on top of the stack, and then
>obtain a pointer
>> to this string. Is this pointer guaranteed to be valid until I call
>luaL_unref() or could
>> the string be moved to an other memory location across function calls?
>
>In practice, pointers to strings will remain valid for as long as
>there is a reference to the string (e.g. by putting it in a table or
>stack). If you follow the reference manual strictly, then pointers to
>strings are only guaranteed to be valid for as long as the string is
>on the stack. While not explicitly stated, userdata pointers will
>remain valid for as long as there is a reference to the userdata, as
>moving them could mess things up.

Ok, thanks. I'm stuck with Lua 5.0.2 anyway so I think it is reasonably
safe to work with the ref'ed string pointer although it is no longer on the
stack.

Hi Timm, btw :-)

Greets,

Andreas
--
"Remember: It's nice to be important but it's more important to be nice!"