[RFC][PATCH v2] Add reallocarray function.
Joseph S. Myers
joseph@codesourcery.com
Mon May 19 15:30:00 GMT 2014
On Sun, 18 May 2014, Rüdiger Sonderfeld wrote:
> diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
> index 00329a2..b75c28f 100644
> --- a/stdlib/stdlib.h
> +++ b/stdlib/stdlib.h
> @@ -479,6 +479,13 @@ extern void *calloc (size_t __nmemb, size_t __size)
> between objects pointed by the old and new pointers. */
> extern void *realloc (void *__ptr, size_t __size)
> __THROW __attribute_warn_unused_result__;
> +/* Re-allocate the previously allocated block in PTR, making the new
> + block large enough for NMEMB elements of SIZE bytes each. */
> +/* __attribute_malloc__ is not used, because if realloc returns
> + the same pointer that was passed to it, aliasing needs to be allowed
> + between objects pointed by the old and new pointers. */
> +extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
> + __THROW __attribute_warn_unused_result__;
How has this patch been tested? This function declaration needs
conditioning on __USE_GNU, as no standard includes this function in
<stdlib.h>; I'd have expected you to get failures of the conform/ tests
for stdlib.h when you ran the testsuite.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list