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

Function read_c_str

plugins/wasm_bpf/util.cpp:9–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7namespace Host {
8
9Expect<const char *> read_c_str(Runtime::Instance::MemoryInstance *memory,
10 uint32_t ptr) {
11 uint32_t tail = ptr;
12 while (true) {
13 auto ch = memory->getBytes(tail, 1);
14 if (!ch.has_value())
15 return Unexpect(ch.error());
16 if (ch.value()[0] == '\0')
17 break;
18 tail++;
19 }
20 uint32_t len = tail - ptr + 1;
21 return memory->getSpan<const char>(ptr, len).data();
22}
23
24} // namespace Host
25} // namespace WasmEdge

Callers

nothing calls this directly

Calls 5

UnexpectFunction · 0.85
getBytesMethod · 0.80
has_valueMethod · 0.45
valueMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected