diff options
Diffstat (limited to 'common/compat.c')
-rw-r--r-- | common/compat.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/common/compat.c b/common/compat.c index 692e2ca..3114724 100644 --- a/common/compat.c +++ b/common/compat.c @@ -487,6 +487,23 @@ strndup (const char *data, #endif /* HAVE_STRNDUP */ +#ifndef HAVE_REALLOCARRAY + +void * +reallocarray (void *ptr, + size_t nmemb, + size_t size) +{ + assert (nmemb > 0 && size > 0); + if (SIZE_MAX / nmemb < size) { + errno = ENOMEM; + return NULL; + } + return realloc (ptr, nmemb * size); +} + +#endif /* HAVE_MEMDUP */ + #ifndef HAVE_STRCONCAT #include <stdarg.h> |