This is the mail archive of the
mailing list for the glibc project.
Re: [RFC][PATCH v2] Add reallocarray function.
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Rüdiger Sonderfeld <ruediger at c-plusplus dot de>
- Cc: Paul Eggert <eggert at cs dot ucla dot edu>, <libc-alpha at sourceware dot org>
- Date: Mon, 19 May 2014 15:02:52 +0000
- Subject: Re: [RFC][PATCH v2] Add reallocarray function.
- Authentication-results: sourceware.org; auth=none
- References: <5379208F dot 8030000 at cs dot ucla dot edu> <2080621 dot 6fAB4UMNoY at descartes>
On Sun, 18 May 2014, Rü 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