From 5c7f5f1b0ba7d5241edb944c3bb024d610839c8b Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Mon, 10 Jun 2013 21:45:26 -0400 Subject: [PATCH] [libfko] use local strndup() if autoconf HAVE_STRNDUP not defined Blair Zajac reported that strndup() is not available on some PPC systems, so this commit switches to use the local lib/fko_util.c implementation similarly to what is done for Windows systems. --- lib/fko_util.c | 4 ++-- lib/fko_util.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/fko_util.c b/lib/fko_util.c index de923657..949af84a 100644 --- a/lib/fko_util.c +++ b/lib/fko_util.c @@ -399,11 +399,11 @@ strtol_wrapper(const char * const str, const int min, } -#ifdef WIN32 +#if defined(WIN32) || !defined(HAVE_STRNDUP) /* Windows does not have strndup, so we well implement it here. * This was the Public Domain C Library (PDCLib). */ -char +char *strndup( const char * s, size_t len ) { char* ns = NULL; diff --git a/lib/fko_util.h b/lib/fko_util.h index 35d29517..9c4d3005 100644 --- a/lib/fko_util.h +++ b/lib/fko_util.h @@ -52,7 +52,7 @@ const char * msg_type_inttostr(const int type); size_t strlcat(char *dst, const char *src, size_t siz); size_t strlcpy(char *dst, const char *src, size_t siz); -#ifdef WIN32 +#if defined(WIN32) || !defined(HAVE_STRNDUP) char * strndup( const char * s, size_t len ); #endif