diff options
| author | Jörg Frings-Fürst <debian@jff.email> | 2026-03-10 13:24:07 +0100 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff.email> | 2026-03-10 13:24:07 +0100 |
| commit | cfd1f17f1a85d95ea12bca8dae42add7dad1ad11 (patch) | |
| tree | 8016486f8ee7157213f2d09ff2491bfa9c94638a /tests/ialloc.h | |
| parent | 14e4d584d0121031ec40e6c35869745f1747ff29 (diff) | |
| parent | 1403307d6e2fb4e7b5d97a35f40d1e95134561ab (diff) | |
Merge branch 'release/debian/1.4.2-1'HEADdebian/1.4.2-1master
Diffstat (limited to 'tests/ialloc.h')
| -rw-r--r-- | tests/ialloc.h | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/tests/ialloc.h b/tests/ialloc.h index 2aa94ae7..97b0e0c5 100644 --- a/tests/ialloc.h +++ b/tests/ialloc.h @@ -1,6 +1,6 @@ /* ialloc.h -- malloc with idx_t rather than size_t - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 @@ -29,9 +29,6 @@ #include <errno.h> #include <stdint.h> #include <stdlib.h> -#if defined __CHERI_PURE_CAPABILITY__ -# include <cheri.h> -#endif _GL_INLINE_HEADER_BEGIN #ifndef IALLOC_INLINE @@ -68,19 +65,7 @@ IALLOC_INLINE void * irealloc (void *p, idx_t s) { - if (s <= SIZE_MAX) - { - /* Work around GNU realloc glitch by treating a zero size as if it - were 1, so that returning NULL is equivalent to failing. */ - p = realloc (p, s | !s); -#if defined __CHERI_PURE_CAPABILITY__ - if (p != NULL) - p = cheri_bounds_set (p, s); -#endif - return p; - } - else - return _gl_alloc_nomem (); + return s <= SIZE_MAX ? realloc (p, s) : _gl_alloc_nomem (); } /* icalloc (num, size) is like calloc (num, size). @@ -112,23 +97,9 @@ icalloc (idx_t n, idx_t s) IALLOC_INLINE void * ireallocarray (void *p, idx_t n, idx_t s) { - if (n <= SIZE_MAX && s <= SIZE_MAX) - { - /* Work around GNU reallocarray glitch by treating a zero size as if - it were 1, so that returning NULL is equivalent to failing. */ - size_t nx = n; - size_t sx = s; - if (n == 0 || s == 0) - nx = sx = 1; - p = reallocarray (p, nx, sx); -#if defined __CHERI_PURE_CAPABILITY__ - if (p != NULL && (n == 0 || s == 0)) - p = cheri_bounds_set (p, 0); -#endif - return p; - } - else - return _gl_alloc_nomem (); + return (n <= SIZE_MAX && s <= SIZE_MAX + ? reallocarray (p, n, s) + : _gl_alloc_nomem ()); } #ifdef __cplusplus |
