forked from rosebudai/OpenRCT2-Web
Provide strndup implementation for platforms missing it
This commit is contained in:
1 parent
9284930d7e
commit
45b3d8362d
2 files changed
+19
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user