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

Method fillBytes

include/runtime/instance/memory.h:184–198  ·  view source on GitHub ↗

Fill the bytes of Data[Offset : Offset + Length - 1] by Val.

Source from the content-addressed store, hash-verified

182
183 /// Fill the bytes of Data[Offset : Offset + Length - 1] by Val.
184 Expect<void> fillBytes(const uint8_t Val, const uint64_t Offset,
185 const uint64_t Length) noexcept {
186 // Check the memory boundary.
187 if (unlikely(!checkAccessBound(Offset, Length))) {
188 spdlog::error(ErrCode::Value::MemoryOutOfBounds);
189 spdlog::error(ErrInfo::InfoBoundary(Offset, Length, getSize()));
190 return Unexpect(ErrCode::Value::MemoryOutOfBounds);
191 }
192
193 // Copy the data.
194 if (likely(Length > 0)) {
195 std::fill(DataPtr + Offset, DataPtr + Offset + Length, Val);
196 }
197 return {};
198 }
199
200 /// Get an uint8 array from Data[Offset : Offset + Length - 1]
201 Expect<void> getArray(uint8_t *Arr, const uint64_t Offset,

Callers 2

runMemoryFillOpMethod · 0.80
proxyMemFillMethod · 0.80

Calls 5

unlikelyFunction · 0.85
InfoBoundaryClass · 0.85
UnexpectFunction · 0.85
errorFunction · 0.50
likelyFunction · 0.50

Tested by

no test coverage detected