| 24 | #else |
| 25 | |
| 26 | char *mystrdup(const char *s) { |
| 27 | size_t len = strlen(s); // Space for length plus nul |
| 28 | char *d = static_cast<char*>(malloc(len + 1)); |
| 29 | if (d == nullptr) return nullptr; // No memory |
| 30 | #ifdef CHAISCRIPT_MSVC |
| 31 | strcpy_s(d, len + 1, s); // Copy the characters |
| 32 | #else |
| 33 | strncpy(d, s, len); // Copy the characters |
| 34 | #endif |
| 35 | d[len] = '\0'; |
| 36 | return d; // Return the new string |
| 37 | } |
| 38 | |
| 39 | char* readline(const char* p) |
| 40 | { |