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

Function mystrdup

samples/fun_call_performance.cpp:26–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24#else
25
26char *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
39char* readline(const char* p)
40{

Callers 1

readlineFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected