MCPcopy Create free account
hub / github.com/MemNixFS/MemNixFS / read

Method read

src/io/mmap_memory_source.cpp:79–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77 const std::string& name() const override { return name_; }
78
79 std::size_t read(u64 offset, void* out, std::size_t len) const override {
80 if (offset >= size_) return 0;
81 // Overflow-safe clamp: `offset + len` can wrap for a huge len and skip
82 // the bound, letting memcpy read past the mapped view (OOB). offset <
83 // size_ here, so `size_ - offset` is always a safe positive bound.
84 if (len > size_ - offset) len = static_cast<std::size_t>(size_ - offset);
85 // Page-fault on demand; OS prefetcher handles streaming patterns.
86 std::memcpy(out, static_cast<const u8*>(view_) + offset, len);
87 return len;
88 }
89
90private:
91 std::string name_;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected