bsdstubs: add pkgconf_reallocarray

master
Ariadne Conill 2022-06-26 04:37:18 +00:00
parent 4c76f6bf01
commit c1579d381c
2 changed files with 21 additions and 0 deletions

View File

@ -137,3 +137,23 @@ pkgconf_strndup(const char *src, size_t len)
{ {
return strndup(src, len); return strndup(src, len);
} }
#ifndef HAVE_REALLOCARRAY
void *
reallocarray(void *ptr, size_t m, size_t n)
{
if (n && m > -1 / n)
{
errno = ENOMEM;
return 0;
}
return realloc(ptr, m * n);
}
#endif
void *
pkgconf_reallocarray(void *ptr, size_t m, size_t n)
{
return reallocarray(ptr, m, n);
}

View File

@ -25,6 +25,7 @@ extern "C" {
PKGCONF_API extern size_t pkgconf_strlcpy(char *dst, const char *src, size_t siz); PKGCONF_API extern size_t pkgconf_strlcpy(char *dst, const char *src, size_t siz);
PKGCONF_API extern size_t pkgconf_strlcat(char *dst, const char *src, size_t siz); PKGCONF_API extern size_t pkgconf_strlcat(char *dst, const char *src, size_t siz);
PKGCONF_API extern char *pkgconf_strndup(const char *src, size_t len); PKGCONF_API extern char *pkgconf_strndup(const char *src, size_t len);
PKGCONF_API extern void *pkgconf_reallocarray(void *ptr, size_t m, size_t n);
#ifdef __cplusplus #ifdef __cplusplus
} }