Skip to content

Commit

Permalink
strdup for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSvoboda committed Jul 7, 2024
1 parent 379ec55 commit c6c220c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/core/libraries/kernel/file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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

0 comments on commit c6c220c

Please sign in to comment.