[PATCH v5] Add reallocarray function.
Zack Weinberg
zackw@panix.com
Mon May 22 18:51:00 GMT 2017
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
More information about the Libc-alpha
mailing list