Provide strndup implementation for platforms missing it

This commit is contained in:
Michał Janiszewski committed 2015-10-30 19:14:05 +01:00
1 parent 9284930d7e
commit 45b3d8362d
2 files changed
+19

No files matched your search

+4
View File
@@ -181,4 +181,8 @@ bool platform_check_steam_overlay_attached();
#endif // __linux__
#if !(POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
char *strndup(const char *src, size_t size);
#endif // !(POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
#endif
+15
View File
@@ -846,4 +846,19 @@ bool platform_check_steam_overlay_attached()
{
return GetModuleHandle("GameOverlayRenderer.dll") != NULL;
}
char *strndup(const char *src, size_t size)
{
size_t len = strnlen(src, size);
char *dst = (char *)malloc(len + 1);
if (dst == NULL)
{
return NULL;
}
dst = memcpy(dst, src, len);
dst[len] = '\0';
return (char *)dst;
}
#endif