diff options
Diffstat (limited to 'src/string.cpp')
-rw-r--r-- | src/string.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/string.cpp b/src/string.cpp index 041fa8e45..9173dc4a5 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -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 */ |