MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / mystrdup

Function mystrdup

src/main.cpp:29–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

readlineFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected