bug-gnulib
[Top][All Lists]
Advanced

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

[Bug-gnulib] Re: xvasprintf and xasprintf


From: Simon Josefsson
Subject: [Bug-gnulib] Re: xvasprintf and xasprintf
Date: Thu, 26 Aug 2004 14:17:09 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

Bruno Haible <address@hidden> 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]