--- Michael G Schwern <[EMAIL PROTECTED]> wrote: 
> On Mon, Dec 06, 2004 at 02:25:42PM -0800, Andrew Savige wrote:
> > --- Michael G Schwern <[EMAIL PROTECTED]> wrote:
> > > Why add that extra auto-sprintf complexity?  Can't the user do the exact
> > > same thing with:
> > > 
> > >   ok(some_func(i), sprintf("some_func(%d)", i));
> > 
> > No. sprintf in C needs a buffer and you don't know how big to make it.
> 
> If the user doesn't know how will ok() know how big to make it?

By the magic of the ANSI C macros: va_start(), va_arg(), va_end().
These macros are provided by the C runtime library and typically require
some assembler to implement. In Nik's _gen_result() function (tap.c) he
employs these macros in harness with vprintf(): in this way, he does not
need to allocate a buffer at all, nor does he need worry about possible
buffer overruns. FWIW, I agree with this implemenatation decision, and
feel it will be well received by C programmers ... unless anyone can
suggest a better alternative, of course.

/-\


Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

Reply via email to