[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gnulib-bug
Subject:    [Bug-gnulib] Re: xvasprintf and xasprintf
From:       Simon Josefsson <jas () extundo ! com>
Date:       2004-08-26 12:17:09
Message-ID: ilubrgy6qm2.fsf () latte ! josefsson ! org
[Download RAW message or body]

Bruno Haible <bruno@clisp.org> writes:

> A similar function exists in GNU gettext:
>
>   /* Format a message and return the freshly allocated resulting string.  */
>   extern char *xasprintf (const char *format, ...)
>        __attribute__ ((__format__ (__printf__, 1, 2)));

Nice.  Is it easy to package as a gnulib module?  I think I would want
to use this.

> Why do you prefer the function to return an 'int' and the caller to do
> error checking against other failures?

FWIW, I see two advantages, although small both ones: the function
would have the same C fingerprint as printf, so you could use it as a
drop in replacement.  Secondly, you might want the length without
doing strlen; and if x*printf support it, you could have '\0x00'
inside the string, so using strlen wouldn't even be correct.

Thanks,
Simon




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic