From 5f59a34ab747dde8ede7357f3431bf06bd6002fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 8 Mar 2026 17:28:33 +0100 Subject: New upstream version 1.4.2 --- tests/xmalloc.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'tests/xmalloc.c') diff --git a/tests/xmalloc.c b/tests/xmalloc.c index 8a715807..545beb35 100644 --- a/tests/xmalloc.c +++ b/tests/xmalloc.c @@ -1,6 +1,6 @@ /* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990-2000, 2002-2006, 2008-2025 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2002-2006, 2008-2026 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,10 +15,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include - #define XALLOC_INLINE _GL_EXTERN_INLINE - +#include #include "xalloc.h" #include "ialloc.h" @@ -29,7 +27,13 @@ #include #include -static void * _GL_ATTRIBUTE_PURE +/* Pacify GCC up to at least 15.2, which otherwise would incorrectly + complain about check_nonnull. */ +#if _GL_GNUC_PREREQ (4, 6) +# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" +#endif + +static void * check_nonnull (void *p) { if (!p) @@ -63,10 +67,7 @@ xcharalloc (size_t n) void * xrealloc (void *p, size_t s) { - void *r = realloc (p, s); - if (!r) - xalloc_die (); - return r; + return check_nonnull (realloc (p, s)); } void * @@ -81,10 +82,7 @@ xirealloc (void *p, idx_t s) void * xreallocarray (void *p, size_t n, size_t s) { - void *r = reallocarray (p, n, s); - if (!r) - xalloc_die (); - return r; + return check_nonnull (reallocarray (p, n, s)); } void * @@ -224,13 +222,13 @@ x2nrealloc (void *p, size_t *pn, size_t s) void * xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s) { - idx_t n0 = *pn; - /* The approximate size to use for initial small allocation requests. This is the largest "small" request for the GNU C library malloc. */ enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; + idx_t n0 = *pn; + /* If the array is tiny, grow it to about (but no greater than) DEFAULT_MXFAST bytes. Otherwise, grow it by about 50%. Adjust the growth according to three constraints: N_INCR_MIN, -- cgit v1.2.3