add strndup() compatibility code
This commit is contained in:
parent
768790eab7
commit
910c4b37b6
|
@ -231,6 +231,7 @@ AC_SUBST(PSL_TESTFILE)
|
|||
|
||||
# check for alloca / alloca.h
|
||||
AC_FUNC_ALLOCA
|
||||
AC_CHECK_FUNCS([strndup])
|
||||
|
||||
# Override the template file name of the generated .pc file, so that there
|
||||
# is no need to rename the template file when the API version changes.
|
||||
|
|
16
src/psl.c
16
src/psl.c
|
@ -93,6 +93,22 @@
|
|||
/* number of elements within an array */
|
||||
#define countof(a) (sizeof(a)/sizeof(*(a)))
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
// I found no strndup on my old SUSE 7.3 test system (gcc 2.95)
|
||||
|
||||
static char *strndup(const char *s, size_t n)
|
||||
{
|
||||
char *dst = malloc(n + 1);
|
||||
|
||||
if (dst) {
|
||||
memcpy(dst, s, n);
|
||||
dst[n] = 0;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SECTION:libpsl
|
||||
* @short_description: Public Suffix List library functions
|
||||
|
|
Loading…
Reference in New Issue