[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: String lifetime (C API)
- From: Chris <coderight@...>
- Date: Thu, 2 Mar 2006 09:30:13 -0500
On 3/2/06, Roberto Ierusalimschy <email@example.com> wrote:
On Tue, Feb 28, 2006 at 10:29:17AM +0200, Asko Kauppi wrote:
> Authors: a word of verdict? :)
- Currently, several API calls may trigger the collector (e.g.,
- On the other hand, in the current implementation, if a string is
anchored somewhere (e.g., in a table's field), it will not be collected;
its pointer will not be invalidated. But that may change in future
It is true that several things change between releases, but to use the
assumption that "it is safe to point to anchored strings inside Lua" is
particularly dangerous. First, because it is not official, it will not
be announced as an incompatibility. Second, you will not get any obvious
error (such as "undefined function") with the new release. Instead, you
will get a very hard-to-find memory bug.
Thanks, I finally decided to just leave everything on the stack and assume it will get cleaned up when the function returns.
Actually, I created a few proxy functions so all I need to do is change
those to whatever behaviour I want, just in case I figure out another
way or want to change it.