reallocarray
¶POSIX specification:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/reallocarray.html
Documentation:
Portability problems fixed by Gnulib:
errno
to EAGAIN
instead of to ENOMEM
. Although POSIX allows
EAGAIN
, the reallocarray
module insists on ENOMEM
which also conforms to POSIX and is GNU-compatible:
Solaris 11.4.
reallocarray (p, n, s)
can succeed even if
multiplying n
by s
would exceed PTRDIFF_MAX
,
which can lead to undefined behavior later:
FreeBSD 13, NetBSD 9, OpenBSD 6, musl 1.2.
reallocarray (p, n, s)
when either n
or s
is zero,
as reallocarray
has the same issues with zero sizes
that realloc
does. See realloc
.
Portability problems not fixed by Gnulib:
reallocarray
, like realloc
, can fail and return a null pointer:
glibc 2.40 and probably other platforms.