bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] vasnprintf cleanup


From: Bruno Haible
Subject: Re: [Bug-gnulib] vasnprintf cleanup
Date: Fri, 15 Oct 2004 14:32:58 +0200
User-agent: KMail/1.5

Derek Robert Price wrote:
> Attached is a very short patch which updates vasnprintf to not access
> lengthp when resultbuf == NULL and lengthp == NULL to avoid annoying
> artificial constructs like the following:
>
>     ...coding happily away...
>     ...
>     {
>        size_t dummy;
>        somevar = asnprintf (NULL, &dummy, "%s/%s", foo, bar);
>     }
>     ...

Hi,

I don't agree with this patch because
  - Generally NULL arguments should be supported only when it provides good
    benefit for frequent cases. The standard in C is that pointer arguments
    must be non-NULL, unless specified explicitly.
  - Adding extra code for allowing NULL, just to save 1 memory store
    instruction, is not worth it.
  - For your case, when you are not interested in the resulting string's size,
    you'll prefer using a function without 'n', such as asprintf() or
    xasprintf().

Furthermore, I don't agree calling a patch that introduces new functionality
and new code a "cleanup". IMO a cleanup is removal of code or otherwise a
simplification.

Bruno





reply via email to

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