From b0afb8fe0ff1d87165af9df61501197a06240dda Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 28 Dec 2025 12:13:40 +0100 Subject: Sync with Gnulib stable-202507 code (a8ac9f9ce5) --- gl/calloc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'gl/calloc.c') diff --git a/gl/calloc.c b/gl/calloc.c index 81dfd3ef..5258c5de 100644 --- a/gl/calloc.c +++ b/gl/calloc.c @@ -1,6 +1,6 @@ /* calloc() function that is glibc compatible. This wrapper function is required at least on Tru64 UNIX 5.1 and mingw. - Copyright (C) 2004-2007, 2009-2024 Free Software Foundation, Inc. + Copyright (C) 2004-2007, 2009-2025 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -17,17 +17,15 @@ /* written by Jim Meyering and Bruno Haible */ +/* Ensure that we call the system's calloc() below. */ +#define _GL_USE_STDLIB_ALLOC 1 #include /* Specification. */ #include #include - -#include "xalloc-oversized.h" - -/* Call the system's calloc below. */ -#undef calloc +#include /* Allocate and zero-fill an NxS-byte block of memory from the heap, even if N or S is zero. */ @@ -35,14 +33,19 @@ void * rpl_calloc (size_t n, size_t s) { +#if !HAVE_MALLOC_0_NONNULL if (n == 0 || s == 0) n = s = 1; +#endif - if (xalloc_oversized (n, s)) +#if !HAVE_MALLOC_PTRDIFF + ptrdiff_t signed_n; + if (ckd_mul (&signed_n, n, s)) { errno = ENOMEM; return NULL; } +#endif void *result = calloc (n, s); -- cgit v1.2.3-74-g34f1