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