Remove redefinition of strndup() which is no longer used in the codebase

This commit is contained in:
Even Rouault
2013-08-12 20:49:19 +02:00
parent b3bce4d594
commit 1a957c2edc
4 changed files with 1 additions and 31 deletions

View File

@@ -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 <syslog.h> header file. */
#undef HAVE_SYSLOG_H

View File

@@ -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])

View File

@@ -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

View File

@@ -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