lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> 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).

-- Roberto