diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2025-10-18 19:06:52 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2025-10-18 19:06:52 +0200 |
commit | 27dae84ed92f1ef0300263091972338d12e78348 (patch) | |
tree | 7c52931f474fafb8a4bd4fd15ca3461c77cdecc2 /tests/calloc.c | |
parent | 4682deeb62247d34de87f8e777f99e2d337fd377 (diff) |
New upstream version 1.4.1upstream/1.4.1upstream
Diffstat (limited to 'tests/calloc.c')
-rw-r--r-- | tests/calloc.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/tests/calloc.c b/tests/calloc.c index 81dfd3ef..66ed0cf9 100644 --- a/tests/calloc.c +++ b/tests/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. + This wrapper function is required at least on mingw. + 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 <config.h> /* Specification. */ #include <stdlib.h> #include <errno.h> - -#include "xalloc-oversized.h" - -/* Call the system's calloc below. */ -#undef calloc +#include <stdckdint.h> /* 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); |