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> 2023-10-20 06:45:24-04:00
log1631dc923d48d8c586e57f793adcdfb97760ceb3
tree36d8e5567bed0adf3cbdbe691c18f5d49b9ff5ac
parent6822a7a1237d0274ac68b9e713db11c45a737998

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;
5151extern void *realloc (void *__ptr, size_t __size)
5252__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
5459/* Re-allocate the previously allocated block in PTR, making the new
5560 block large enough for NMEMB elements of SIZE bytes each. */
5661/* __attribute_malloc__ is not used, because if reallocarray returns
......@@ -59,6 +64,7 @@ __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2));
5964extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
6065 __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2, 3))
6166 __attr_dealloc_free;
67#endif /* glibc v2.26 and later */
6268
6369/* Free a block allocated by `malloc', `realloc' or `calloc'. */
6470extern 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)
686686/* Free a block allocated by `malloc', `realloc' or `calloc'. */
687687extern 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
689694#ifdef __USE_MISC
690695/* Re-allocate the previously allocated block in PTR, making the new
691696 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)
701706extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
702707 __THROW __attr_dealloc (reallocarray, 1);
703708#endif
709#endif /* glibc v2.26 and later */
704710
705711#ifdef __USE_MISC
706712# include <alloca.h>