summaryrefslogtreecommitdiff
path: root/tests/calloc.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2026-03-10 13:24:07 +0100
committerJörg Frings-Fürst <debian@jff.email>2026-03-10 13:24:07 +0100
commitcfd1f17f1a85d95ea12bca8dae42add7dad1ad11 (patch)
tree8016486f8ee7157213f2d09ff2491bfa9c94638a /tests/calloc.c
parent14e4d584d0121031ec40e6c35869745f1747ff29 (diff)
parent1403307d6e2fb4e7b5d97a35f40d1e95134561ab (diff)
Merge branch 'release/debian/1.4.2-1'HEADdebian/1.4.2-1master
Diffstat (limited to 'tests/calloc.c')
-rw-r--r--tests/calloc.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/tests/calloc.c b/tests/calloc.c
index 81dfd3ef..b4ca8f89 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-2026 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);