mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-21 03:54:45 +00:00
strdup for Windows
This commit is contained in:
parent
379ec554a8
commit
c6c220c323
1 changed files with 14 additions and 0 deletions
|
@ -10,6 +10,8 @@
|
|||
#include "core/libraries/kernel/file_system.h"
|
||||
#include "core/libraries/libs.h"
|
||||
#include "libkernel.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
namespace Libraries::Kernel {
|
||||
|
||||
|
@ -452,4 +454,16 @@ void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) {
|
|||
posix_open); // _open shoudld be equal to open function
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Implementation of strdup for Windows, as it is not standard
|
||||
char* strdup(const char* str) {
|
||||
size_t len = strlen(str) + 1; // +1 for the final '\0'
|
||||
char* dup = (char*)malloc(len);
|
||||
if (dup) {
|
||||
strcpy_s(dup, len, str); // Using strcpy_s for safety
|
||||
}
|
||||
return dup;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace Libraries::Kernel
|
||||
|
|
Loading…
Add table
Reference in a new issue