Behave in an OpenBSD compatible way for 0.

This commit is contained in:
christos 2015-03-10 13:05:13 +00:00
parent 49345864e2
commit f7b1663b18
1 changed files with 4 additions and 1 deletions

View File

@ -30,7 +30,7 @@
*/
#define _OPENBSD_SOURCE
#include <sys/cdefs.h>
__RCSID("$NetBSD: reallocarray.c,v 1.3 2015/02/17 20:44:42 christos Exp $");
__RCSID("$NetBSD: reallocarray.c,v 1.4 2015/03/10 13:05:13 christos Exp $");
#define _OPENBSD_SOURCE
#include <errno.h>
@ -39,6 +39,9 @@ __RCSID("$NetBSD: reallocarray.c,v 1.3 2015/02/17 20:44:42 christos Exp $");
void *
reallocarray(void *optr, size_t nmemb, size_t size)
{
if (nmemb == 0 || size == 0)
return realloc(optr, 0);
int e = reallocarr(&optr, nmemb, size);
if (e == 0)