This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v5] Add reallocarray function.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]