forked from ariadne/pkgconf
bsdstubs: add pkgconf_reallocarray
parent
4c76f6bf01
commit
c1579d381c
|
@ -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);
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue