summaryrefslogtreecommitdiff
path: root/tests/malloc.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2025-10-18 19:06:52 +0200
committerJörg Frings-Fürst <debian@jff.email>2025-10-18 19:06:52 +0200
commit27dae84ed92f1ef0300263091972338d12e78348 (patch)
tree7c52931f474fafb8a4bd4fd15ca3461c77cdecc2 /tests/malloc.c
parent4682deeb62247d34de87f8e777f99e2d337fd377 (diff)
New upstream version 1.4.1upstream/1.4.1upstream
Diffstat (limited to 'tests/malloc.c')
-rw-r--r--tests/malloc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/malloc.c b/tests/malloc.c
index 2a7867a1..5642c83c 100644
--- a/tests/malloc.c
+++ b/tests/malloc.c
@@ -1,6 +1,6 @@
/* malloc() function that is glibc compatible.
- Copyright (C) 1997-1998, 2006-2007, 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 1997-1998, 2006-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,28 +17,33 @@
/* written by Jim Meyering and Bruno Haible */
+/* Ensure that we call the system's malloc() below. */
#define _GL_USE_STDLIB_ALLOC 1
#include <config.h>
#include <stdlib.h>
#include <errno.h>
-
-#include "xalloc-oversized.h"
+#include <stdckdint.h>
/* Allocate an N-byte block of memory from the heap, even if N is 0. */
void *
rpl_malloc (size_t n)
{
+#if !HAVE_MALLOC_0_NONNULL
if (n == 0)
n = 1;
+#endif
- if (xalloc_oversized (n, 1))
+#if !HAVE_MALLOC_PTRDIFF
+ ptrdiff_t signed_n;
+ if (ckd_add (&signed_n, n, 0))
{
errno = ENOMEM;
return NULL;
}
+#endif
void *result = malloc (n);