authorgravatar for pat.github@tullmann.orgPat Tullmann <pat.github@tullmann.org> 2023-10-18 21:28:09-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-05 22:43:53-07:00
log8a82496520ef25da9203dce527571c8e0574e6a6
tree5d7baf1902e48f237b222f19407f3a205494239b
parent9f9fa2df932fafe21134fc9bbf82fec282739d70

glibc headers: reallocarray added to glibc in v2.26

Here's the glibc commit that adds reallocarray to glibc: https://sourceware.org/git/?p=glibc.git;a=commit;h=2e0bbbfbf95fc9e22692e93658a6fbdd2d4554da The reallocarray symbol is declared in both stdlib.h and malloc.h. Fix #17607

2 files changed, 12 insertions(+), 0 deletions(-)

lib/libc/include/generic-glibc/malloc.h+6
...@@ -51,6 +51,11 @@ __THROW __attribute_malloc__ __attribute_alloc_size__ ((1, 2)) __wur;...@@ -51,6 +51,11 @@ __THROW __attribute_malloc__ __attribute_alloc_size__ ((1, 2)) __wur;
51extern void *realloc (void *__ptr, size_t __size)51extern void *realloc (void *__ptr, size_t __size)
52__THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2));52__THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2));
5353
54/*
55 * reallocarray introduced in glibc 2.26
56 * https://sourceware.org/git/?p=glibc.git;a=commit;h=2e0bbbfbf95fc9e22692e93658a6fbdd2d4554da
57 */
58#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 26) || __GLIBC__ > 2
54/* Re-allocate the previously allocated block in PTR, making the new59/* Re-allocate the previously allocated block in PTR, making the new
55 block large enough for NMEMB elements of SIZE bytes each. */60 block large enough for NMEMB elements of SIZE bytes each. */
56/* __attribute_malloc__ is not used, because if reallocarray returns61/* __attribute_malloc__ is not used, because if reallocarray returns
...@@ -59,6 +64,7 @@ __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2));...@@ -59,6 +64,7 @@ __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2));
59extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)64extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
60 __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2, 3))65 __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2, 3))
61 __attr_dealloc_free;66 __attr_dealloc_free;
67#endif /* glibc v2.26 and later */
6268
63/* Free a block allocated by `malloc', `realloc' or `calloc'. */69/* Free a block allocated by `malloc', `realloc' or `calloc'. */
64extern void free (void *__ptr) __THROW;70extern void free (void *__ptr) __THROW;
lib/libc/include/generic-glibc/stdlib.h+6
...@@ -686,6 +686,11 @@ extern void *realloc (void *__ptr, size_t __size)...@@ -686,6 +686,11 @@ extern void *realloc (void *__ptr, size_t __size)
686/* Free a block allocated by `malloc', `realloc' or `calloc'. */686/* Free a block allocated by `malloc', `realloc' or `calloc'. */
687extern void free (void *__ptr) __THROW;687extern void free (void *__ptr) __THROW;
688688
689/*
690 * reallocarray introduced in glibc 2.26
691 * https://sourceware.org/git/?p=glibc.git;a=commit;h=2e0bbbfbf95fc9e22692e93658a6fbdd2d4554da
692 */
693#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 26) || __GLIBC__ > 2
689#ifdef __USE_MISC694#ifdef __USE_MISC
690/* Re-allocate the previously allocated block in PTR, making the new695/* Re-allocate the previously allocated block in PTR, making the new
691 block large enough for NMEMB elements of SIZE bytes each. */696 block large enough for NMEMB elements of SIZE bytes each. */
...@@ -701,6 +706,7 @@ extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)...@@ -701,6 +706,7 @@ extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
701extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)706extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
702 __THROW __attr_dealloc (reallocarray, 1);707 __THROW __attr_dealloc (reallocarray, 1);
703#endif708#endif
709#endif /* glibc v2.26 and later */
704710
705#ifdef __USE_MISC711#ifdef __USE_MISC
706# include <alloca.h>712# include <alloca.h>