[patch] varargs use
David Zeuthen
david@fubar.dk
Sat, 20 Dec 2003 19:17:05 +0100
On Sat, 2003-12-20 at 19:04, Havoc Pennington wrote:
> On Sat, 2003-12-20 at 12:56, David Zeuthen wrote:
> > +
> > + va_copy(args_copy, args);
> > +
>
> I'm not sure va_copy is portable; if not you may be able to
> va_start/va_end twice. I think glib has a configure check for va_copy is
> where I get the idea it's not portable.
>
It's C99, so probably not that portable. Btw, using va_start/va_end is
not possible as the caller gives the va_list, yes?.
Looking at the function, the only reason for using args twice is to
compute the length of the string to append before growing the string.
Hmm.. Can we get away with allocating memory, either on the stack or the
heap, to print the string into and then appending it later? In this
scenario we would have to have a maximum length of what to append. That
looks ugly though.
> > + va_end(args_copy);
>
> Here and on the va_copy need a space before the parens.
Of course, I could also commit now with these two space, and leave the
problem to someone else later :-)
Cheers,
David