[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: String lifetime (C API)
- From: roberto@... (Roberto Ierusalimschy)
- Date: Thu, 2 Mar 2006 11:18:38 -0300
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.,
lua_pushstring, lua_tolstring).
- 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
releases.
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.
-- Roberto