]> Savannah Git Hosting - gnulib.git/commitdiff
calloc: depend on stdckdint not xalloc-oversized
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 3 Nov 2024 19:11:03 +0000 (11:11 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 5 Nov 2024 05:40:17 +0000 (21:40 -0800)
* lib/calloc.c: Include stdckdint.h, xalloc-oversized.h.
(rpl_calloc): Use ckd_mul instead of xalloc_oversized.
* modules/calloc-gnu, modules/calloc-posix:
(Depends-on): Depend on stdckdint, not xalloc-oversized.

ChangeLog
lib/calloc.c
modules/calloc-gnu
modules/calloc-posix

index a2b5a45e3ecdf87d8ff6794f18e43543ccf2a1da..af6fce7f00d5ca9d24089467674aab1229c06e4c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2024-11-04  Paul Eggert  <eggert@cs.ucla.edu>
 
+       calloc: depend on stdckdint not xalloc-oversized
+       * lib/calloc.c: Include stdckdint.h, xalloc-oversized.h.
+       (rpl_calloc): Use ckd_mul instead of xalloc_oversized.
+       * modules/calloc-gnu, modules/calloc-posix:
+       (Depends-on): Depend on stdckdint, not xalloc-oversized.
+
        malloc etc. tests: use volatile more consistently
        Typically it’s ineffective to use ‘void *volatile p’
        when testing malloc and similar functions, as the compiler
index 81dfd3efb53e297e430075bf612f150b81a86309..801b6720786b2bd9a943be8283ea26d79251f955 100644 (file)
@@ -23,8 +23,7 @@
 #include <stdlib.h>
 
 #include <errno.h>
-
-#include "xalloc-oversized.h"
+#include <stdckdint.h>
 
 /* Call the system's calloc below.  */
 #undef calloc
@@ -38,7 +37,8 @@ rpl_calloc (size_t n, size_t s)
   if (n == 0 || s == 0)
     n = s = 1;
 
-  if (xalloc_oversized (n, s))
+  ptrdiff_t signed_n;
+  if (ckd_mul (&signed_n, n, s))
     {
       errno = ENOMEM;
       return NULL;
index f3fb393e53c3f6758204e84a5483d1564b1d54b6..63f498f0d4b2fc9112575c91e58757369c0aa8a4 100644 (file)
@@ -8,7 +8,7 @@ m4/calloc.m4
 Depends-on:
 calloc-posix
 extensions-aix
-xalloc-oversized     [test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1]
+stdckdint            [test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1]
 
 configure.ac:
 gl_FUNC_CALLOC_GNU
index 5bf5ab8676a518e32e46a1c3581afaa3aa18d991..e455296d7515d71f53421a8e3ffaec144502a8b0 100644 (file)
@@ -7,8 +7,8 @@ m4/calloc.m4
 m4/malloc.m4
 
 Depends-on:
+stdckdint            [test $REPLACE_CALLOC_FOR_CALLOC_POSIX = 1]
 stdlib
-xalloc-oversized     [test $REPLACE_CALLOC_FOR_CALLOC_POSIX = 1]
 
 configure.ac:
 gl_FUNC_CALLOC_POSIX