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

Function createNullTerminatedString

lib/host/wasi/inode-linux.cpp:120–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120std::pair<const char *, std::unique_ptr<char[]>>
121createNullTerminatedString(std::string_view View) noexcept {
122 const char *CStr = nullptr;
123 std::unique_ptr<char[]> Buffer;
124 if (!View.empty()) {
125 if (const auto Pos = View.find_first_of('\0');
126 Pos != std::string_view::npos) {
127 CStr = View.data();
128 } else {
129 Buffer = std::make_unique<char[]>(View.size() + 1);
130 std::copy(View.begin(), View.end(), Buffer.get());
131 CStr = Buffer.get();
132 }
133 }
134 return {CStr, std::move(Buffer)};
135}
136
137} // namespace
138

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