MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / createNullTerminatedString

Function createNullTerminatedString

lib/host/wasi/inode-macos.cpp:97–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97std::pair<const char *, std::unique_ptr<char[]>>
98createNullTerminatedString(std::string_view View) noexcept {
99 const char *CStr = nullptr;
100 std::unique_ptr<char[]> Buffer;
101 if (!View.empty()) {
102 if (const auto Pos = View.find_first_of('\0');
103 Pos != std::string_view::npos) {
104 CStr = View.data();
105 } else {
106 Buffer = std::make_unique<char[]>(View.size() + 1);
107 std::copy(View.begin(), View.end(), Buffer.get());
108 CStr = Buffer.get();
109 }
110 }
111 return {CStr, std::move(Buffer)};
112}
113
114} // namespace
115

Callers 1

getAddrinfoMethod · 0.70

Calls 6

emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected