Fill the bytes of Data[Offset : Offset + Length - 1] by Val.
| 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, |
no test coverage detected