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