Hash :
295626fb
Author :
Date :
2021-04-18T13:58:56
malloc-posix, realloc-posix, calloc-posix: Document affected platforms. * doc/posix-functions/malloc.texi: Re-add platforms list. * doc/posix-functions/realloc.texi: Likewise. * doc/posix-functions/calloc.texi: Likewise.
@node calloc
@section @code{calloc}
@findex calloc
POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/calloc.html}
Gnulib module: calloc-posix
Portability problems fixed by Gnulib:
@itemize
@item
Upon failure, the function does not set @code{errno} to @code{ENOMEM} on
some platforms:
mingw, MSVC 14.
@item
On some platforms, @code{calloc (n, s)} can succeed even if
multiplying @code{n} by @code{s} would exceed @code{PTRDIFF_MAX} or
@code{SIZE_MAX}. Although failing to check for exceeding
@code{PTRDIFF_MAX} is arguably allowed by POSIX it can lead to
undefined behavior later, so @code{calloc-posix} does not allow
going over the limit.
@end itemize
Extension: Gnulib provides a module @samp{calloc-gnu} that substitutes a
@code{calloc} implementation that behaves more like the glibc implementation.
It fixes this portability problem:
@itemize
@item
@code{calloc (0, s)} and @code{calloc (n, 0)} return @code{NULL} on success
on some platforms:
AIX 7.2.
@end itemize