[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luaL_Buffer use question
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 14 Mar 2017 11:25:51 -0300
> I am currently investigating the use of a luaL_Buffer for storing
> data I read from some place until all is read an I am ready to
> return it as a string. Whilst basic usage is quite straightforward,
> I don't quite see what I am supposed to do when, during the buildup
> of a string with a luaL_Buffer, an error occurs and I am not
> interested in it's contents anymore and instead want to return
> something else (like nil + an error message). Can I safely abandon
> the buffer, or do I need to finalize it with luaL_pushresult() in
> any case and just pop the result off the stack? If the latter, can I
> somehow avoid the new string getting interned (for speed reasons)?
> This needs to work with lua 5.1-5.3, in case there are any
> differences in this regard.
It is safe to "abandon" a buffer (that is, to finish a function
that is using a buffer without pushing its contents).
-- Roberto