[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: want luaL_verror()
- From: Iain Hibbert <plunky@...>
- Date: Tue, 27 Nov 2012 12:00:41 +0000 (GMT)
On Tue, 27 Nov 2012, Roberto Ierusalimschy wrote:
> > Thinking more about it: Can such a function ever be implemented
> > "right" (without additional parameters)? It might depend on the
> > caller if va_end must be called or should not be called.
>
> The standard says this:
>
> The object ap may be passed as an argument to another function; if that
> function invokes the va_arg macro with parameter ap, the value of ap in
> the calling function is indeterminate and shall be passed to the va_end
> macro prior to any further reference to ap.
>
> So, it seems that, as long as the calling function does not do any
> further reference to ap (our va_list), macro va_end does not need
> to be called.
>
> It also says this:
>
> The va_end macro facilitates a normal return from the function whose
> variable argument list was referred to by the expansion of the va_start
> macro, or the function containing the expansion of the va_copy macro,
> that initialized the va_list ap.
>
> Again, it seems that we do not need to call va_end if the function did
> not call va_start (or va_copy).
That is correct, but because luaL_error() does not actually return, the
calling function of luaL_verror() will never be returned to, and thus the
va_end() that is there will never be called..
in many (most?) compiler implementations, this will not be an issue, but
it is not beyond the bounds of reason that the way that varargs is
implemented means that va_start() allocates some memory and va_end()
releases it.
regards,
iain
- References:
- want luaL_verror(), John Belmonte
- Re: want luaL_verror(), Roberto Ierusalimschy
- Re: want luaL_verror(), John Belmonte
- Re: want luaL_verror(), Roberto Ierusalimschy
- Re: want luaL_verror(), Coda Highland
- Re: want luaL_verror(), Roberto Ierusalimschy
- RE: want luaL_verror(), Richter, Jörg
- RE: want luaL_verror(), Richter, Jörg
- Re: want luaL_verror(), Roberto Ierusalimschy