[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [NOOB] "remember" function
- From: Javier Guerra Giraldez <javier@...>
- Date: Thu, 23 Aug 2007 16:30:46 -0500
On Thursday 23 August 2007, David Given wrote:
> The value of ret isn't the problem --- it's the string data that it's
> pointing at. That data is owned by Lua, and the garbage collector is at
note that this isn't a Lua-specific issue. when using any C library, if
you're given a pointer, you ALWAYS have to ask "who owns this data?". in the
Lua case, it's clearly stated in the manual:
"Because Lua has garbage collection, there is no guarantee that the pointer
returned by lua_tolstring will be valid after the corresponding value is
removed from the stack."
not giving enough time for this kind of things is what gives pointers (and C)
their bad reputation.
Description: PGP signature