diff options
| author | Jörg Frings-Fürst <debian@jff.email> | 2025-10-18 19:07:35 +0200 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff.email> | 2025-10-18 19:07:35 +0200 |
| commit | fa23d938c040bc8af305a31fa874df55b2a02576 (patch) | |
| tree | 9704e2f7bd8962ea8911cd6f4e2d37227d7eff2e /tests/calloc.c | |
| parent | df9dbf9b0915e432a4a2c4182f60af36374eaaab (diff) | |
| parent | 693ae7b71dfdd1a8146266b5794a71c0dbe5dff0 (diff) | |
Merge branch 'feature/upstream' into develop
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); |
