1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 11:33:03 +01:00

Provide strndup implementation for platforms missing it

This commit is contained in:
Michał Janiszewski
2015-10-30 16:08:49 +01:00
parent 9284930d7e
commit 45b3d8362d
2 changed files with 19 additions and 0 deletions

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

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