(svn r14154) -Fix (r14153): strndup is a GNU extension, so it doesn't exist on all platforms
This commit is contained in:
@@ -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 */
|
||||
|
Reference in New Issue
Block a user