summaryrefslogtreecommitdiff
path: root/tests/calloc.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2025-10-18 19:07:08 +0200
committerJörg Frings-Fürst <debian@jff.email>2025-10-18 19:07:08 +0200
commit693ae7b71dfdd1a8146266b5794a71c0dbe5dff0 (patch)
tree9704e2f7bd8962ea8911cd6f4e2d37227d7eff2e /tests/calloc.c
parentb8b9b0ac61ac47dddc58717f23619f8b06640498 (diff)
parent27dae84ed92f1ef0300263091972338d12e78348 (diff)
Update upstream source from tag 'upstream/1.4.1'
Update to upstream version '1.4.1' with Debian dir 8add41ffbfe3e6636eec0ec134c5af96832cc143
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..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);