summaryrefslogtreecommitdiff
path: root/lib/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/malloc.c')
-rw-r--r--lib/malloc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/malloc.c b/lib/malloc.c
index 2a7867a1..5642c83c 100644
--- a/lib/malloc.c
+++ b/lib/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);