From 1a957c2edc4df1ae3ac5396209e19ba8355a624b Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 12 Aug 2013 20:49:19 +0200 Subject: [PATCH] Remove redefinition of strndup() which is no longer used in the codebase --- config.h.in | 3 --- configure.in | 2 +- json_object.c | 4 ---- json_tokener.c | 23 ----------------------- 4 files changed, 1 insertion(+), 31 deletions(-) diff --git a/config.h.in b/config.h.in index b8b2d17..a912bb0 100644 --- a/config.h.in +++ b/config.h.in @@ -68,9 +68,6 @@ /* Define to 1 if you have the `strncasecmp' function. */ #undef HAVE_STRNCASECMP -/* Define to 1 if you have the `strndup' function. */ -#undef HAVE_STRNDUP - /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H diff --git a/configure.in b/configure.in index c5494a9..64f9cbe 100644 --- a/configure.in +++ b/configure.in @@ -35,7 +35,7 @@ AC_FUNC_VPRINTF AC_FUNC_MEMCMP AC_FUNC_MALLOC AC_FUNC_REALLOC -AC_CHECK_FUNCS(strcasecmp strdup strndup strerror snprintf vsnprintf vasprintf open vsyslog strncasecmp setlocale) +AC_CHECK_FUNCS(strcasecmp strdup strerror snprintf vsnprintf vasprintf open vsyslog strncasecmp setlocale) #check if .section.gnu.warning accepts long strings (for __warn_references) AC_LANG_PUSH([C]) diff --git a/json_object.c b/json_object.c index e12c440..df1a62e 100644 --- a/json_object.c +++ b/json_object.c @@ -34,10 +34,6 @@ # error You do not have strdup on your system. #endif /* HAVE_STRDUP */ -#if !defined(HAVE_STRNDUP) - char* strndup(const char* str, size_t n); -#endif /* !HAVE_STRNDUP */ - #if !defined(HAVE_SNPRINTF) && defined(_MSC_VER) /* MSC has the version as _snprintf */ # define snprintf _snprintf diff --git a/json_tokener.c b/json_tokener.c index a6924a1..24eddb2 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -170,29 +170,6 @@ struct json_object* json_tokener_parse_verbose(const char *str, enum json_tokene return obj; } - -#if !HAVE_STRNDUP -/* CAW: compliant version of strndup() */ -char* strndup(const char* str, size_t n) -{ - if(str) { - size_t len = strlen(str); - size_t nn = json_min(len,n); - char* s = (char*)malloc(sizeof(char) * (nn + 1)); - - if(s) { - memcpy(s, str, nn); - s[nn] = '\0'; - } - - return s; - } - - return NULL; -} -#endif - - #define state tok->stack[tok->depth].state #define saved_state tok->stack[tok->depth].saved_state #define current tok->stack[tok->depth].current -- 2.49.0