MCPcopy Create free account
hub / github.com/boutproject/BOUT-dev / copy_string

Function copy_string

src/sys/utils.cxx:44–54  ·  view source on GitHub ↗

Allocate memory for a copy of given string

Source from the content-addressed store, hash-verified

42
43// Allocate memory for a copy of given string
44char* copy_string(const char* s) {
45
46 if (s == nullptr) {
47 return nullptr;
48 }
49
50 const auto n = strlen(s);
51 auto s2 = static_cast<char*>(malloc(n + 1));
52 strcpy(s2, s);
53 return s2;
54}
55
56// Convert a string to lower case
57const std::string lowercase(const std::string& str) {

Callers 1

TESTFunction · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68