bug-gnulib
[Top][All Lists]
Advanced

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

xmalloc.c's xcalloc performs unnecessary test for N*S overflow


From: Jim Meyering
Subject: xmalloc.c's xcalloc performs unnecessary test for N*S overflow
Date: Thu, 16 Jun 2005 12:37:18 +0200

Currently, the xalloc module doesn't depend on any other.
I think it should depend at least on the calloc module.
If it did so, the test for overflow

  /* Test for overflow, since some calloc implementations don't have
     proper overflow checks.  */
  if (xalloc_oversized (n, s) || (! (p = calloc (n, s)) && n != 0))

could be removed, since it would then be guaranteed to use
a working calloc function.

As it stands, if I use both of the xalloc and calloc modules,
calling xcalloc ends up performing the overflow check twice,
first in xcalloc itself (above), and then again in calloc.

Any objection to such changes?




reply via email to

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