This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v5] Add reallocarray function.
- From: Zack Weinberg <zackw at panix dot com>
- To: Dennis Wölfing <denniswoelfing at gmx dot de>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 22 May 2017 14:51:51 -0400
- Subject: Re: [PATCH v5] Add reallocarray function.
- Authentication-results: sourceware.org; auth=none
- References: <1b314b1b-7242-8163-bbc9-135b84ca226b@gmx.de> <xnmva4hhri.fsf@greed.delorie.com>
Looks good to me, except for two things in the documentation:
> +... except that @code{reallocarray} fails if the
> +multiplication overflows. If the multiplication does overflow,
> +@code{reallocarray} sets @code{errno} to @code{ENOMEM} and returns
> +a null pointer and the original block remains unchanged.
First, this is repeating itself. I suggest instead
... except that @code{reallocarray} fails safely if the the
multiplication overflows, by setting @code{errno} to @code{ENOMEM},
returning a null pointer, and leaving the original block unchanged.
> +@code{reallocarray} should be used instead of @code{realloc} when the new size
> +of the allocated block is the result of a multiplication that might overflow.
> +@end deftypefun
Second, we don't have automatic generation of portability notes yet,
so you need to write one by hand:
@code{reallocarray} should be used instead of @code{realloc} when
the new size of the allocated block is the result of a
multiplication that might overflow.
@strong{Portability Note:} This function is not part of any
standard. It was first introduced in OpenBSD 5.6.
@end deftypefun
zw