bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH 4/8] xalloc: new function xreallocarray


From: Bruno Haible
Subject: Re: [PATCH 4/8] xalloc: new function xreallocarray
Date: Thu, 22 Apr 2021 02:18:34 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-206-generic; KDE/5.18.0; x86_64; ; )

Paul Eggert wrote:
> +     xalloc: new function xreallocarray
> +     This effectively replaces xnmalloc, which perhaps should be deprecated.
> +     The name xreallocarray should be easier to remember now that
> +     reallocarray is a standard GNU function.

I disagree that xnmalloc should be deprecated. In 90% of the cases where
I use xnmalloc() or its macro equivalent XNMALLOC, it's for arrays that
get allocated once and freed once.

xnmalloc and XNMALLOC take 2 arguments, whereas xreallocarray takes 3
arguments. It is often possible to express a function with a simple
interface as a special case of a more complex function. If, in many
use-cases, the simpler function is sufficient, users should not be
forced to understand the more complex function.

No one has ever proposed to deprecate malloc(), although it is a special
case of realloc(). Or to deprecate gettext(), on the grounds that it is
a special case of dcgettext().

Bruno




reply via email to

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