(svn r14154) -Fix (r14153): strndup is a GNU extension, so it doesn't exist on all platforms

This commit is contained in:
glx
2008-08-24 17:02:21 +00:00
parent 7ceb1252a2
commit 4bb40a7d44
3 changed files with 22 additions and 1 deletions

View File

@@ -304,3 +304,14 @@ size_t Utf8TrimString(char *s, size_t maxlen)
*s = '\0';
return length;
}
#ifndef _GNU_SOURCE
#include "core/math_func.hpp"
char *strndup(const char *s, size_t len)
{
len = min(strlen(s), len);
char *tmp = CallocT<char>(len + 1);
memcpy(tmp, s, len);
return tmp;
}
#endif /* !_GNU_SOURCE */