tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: reallocarr(3)



On Thu, 05 Feb 2015 21:09:34 +0000, Christos Zoulas wrote:

> That's not the only problem. What does reallocarray(ptr, 10, 0)
> return in the current OpenBSD implementation? What should it return?
> How about reallocarray(ptr, 0, 10)? When reallocarray returns NULL,
> can one check errno to determine if the allocation failed?

It returns a non-NULL pointer to an address that has no read or
write permissions (so access via it will fault).  This is the same
behavior as malloc(0) and calloc(n, 0) or calloc(0, n) on OpenBSD.

Neither ISO C nor POSIX require that malloc(0) return a NULL pointer
so there is really no ambiguity with reallocarrar() or calloc() on
OpenBSD.

 - todd


Home | Main Index | Thread Index | Old Index