MCPcopy Index your code
hub / github.com/explodingcamera/tinywasm / copy_within

Method copy_within

crates/tinywasm/src/store/table.rs:83–99  ·  view source on GitHub ↗
(&mut self, dst: usize, src: usize, len: usize)

Source from the content-addressed store, hash-verified

81 }
82
83 pub(crate) fn copy_within(&mut self, dst: usize, src: usize, len: usize) -> Result<(), Trap> {
84 // Calculate the end of the source slice
85 let src_end = src.checked_add(len).ok_or_else(|| self.trap_oob(src, len))?;
86 if src_end > self.elements.len() {
87 return Err(self.trap_oob(src, len));
88 }
89
90 // Calculate the end of the destination slice
91 let dst_end = dst.checked_add(len).ok_or_else(|| self.trap_oob(dst, len))?;
92 if dst_end > self.elements.len() {
93 return Err(self.trap_oob(dst, len));
94 }
95
96 // Perform the copy
97 self.elements.copy_within(src..src_end, dst);
98 Ok(())
99 }
100
101 pub(crate) fn set(&mut self, table_idx: TableAddr, value: TableElement) -> Result<(), Trap> {
102 if table_idx as usize >= self.elements.len() {

Callers 4

exec_memory_copyMethod · 0.45
exec_table_copyMethod · 0.45
truncate_keepMethod · 0.45
select_manyMethod · 0.45

Calls 2

trap_oobMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected