MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / write_all

Method write_all

crates/tinywasm/src/store/memory/paged.rs:191–209  ·  view source on GitHub ↗
(&mut self, addr: usize, src: &[u8])

Source from the content-addressed store, hash-verified

189
190 #[inline(always)]
191 fn write_all(&mut self, addr: usize, src: &[u8]) -> Option<()> {
192 let end = self.checked_end(addr, src.len())?;
193 let mut pos = addr;
194 let mut src_offset = 0;
195
196 while pos < end {
197 let chunk_idx = pos >> self.chunk_shift;
198 let chunk_offset = pos & self.chunk_mask;
199 let copy_len = min(self.chunk_size - chunk_offset, end - pos);
200
201 let chunk = self.chunk_mut(chunk_idx).ok()?;
202 chunk[chunk_offset..chunk_offset + copy_len].copy_from_slice(&src[src_offset..src_offset + copy_len]);
203
204 pos += copy_len;
205 src_offset += copy_len;
206 }
207
208 Some(())
209 }
210
211 #[inline(always)]
212 fn fill(&mut self, addr: usize, len: usize, val: u8) -> Option<()> {

Callers 7

copy_withinMethod · 0.45
write_16Method · 0.45
write_32Method · 0.45
write_64Method · 0.45
write_128Method · 0.45

Calls 4

checked_endMethod · 0.80
chunk_mutMethod · 0.80
lenMethod · 0.45
copy_from_sliceMethod · 0.45