bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] revised xvasprintf module


From: Bruno Haible
Subject: Re: [Bug-gnulib] revised xvasprintf module
Date: Wed, 8 Sep 2004 14:15:57 +0200
User-agent: KMail/1.5

Oskar Liljeblad wrote:
> Here's the revised xvasprintf module.

Thanks, I've added the new module, with some doc tweaks:

/* Write formatted output to a string dynamically allocated with malloc().
   If the memory allocation succeeds, store the address of the string in
   *RESULT and return the number of resulting bytes, excluding the trailing
   NUL.  Upon [ENOMEM] memory allocation error, call xalloc_die.
   On some other error
     - [EOVERFLOW] resulting string length is > INT_MAX,
     - [EINVAL] invalid format string,
     - [EILSEQ] error during conversion between wide and multibyte characters,
   return NULL.  */

In most cases, the programmer doesn't want to check the result against NULL.
He can ensure easily that no EINVAL and no EILSEQ error occurs, but cannot
protect himself against EOVERFLOW. Therefore I would be in favour of handling
EOVERFLOW in the xvasprintf() function as well. What do you think?

Bruno





reply via email to

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