MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / read_u16

Function read_u16

crates/virtual-machine/src/elf_parser.rs:99–107  ·  view source on GitHub ↗

Read a 16-bit little-endian value from bytes at the given offset

(bytes: &[u8], offset: usize)

Source from the content-addressed store, hash-verified

97 .checked_add(2)
98 .ok_or_else(|| VmError::Other("ELF read overflow".to_owned()))?;
99 let slice = bytes
100 .get(offset..end)
101 .ok_or_else(|| VmError::Other("ELF read out of bounds".to_owned()))?;
102 Ok(u16::from_le_bytes([slice[0], slice[1]]))
103}
104
105fn read_u32(bytes: &[u8], offset: usize) -> Result<u32, VmError> {
106 let end = offset
107 .checked_add(4)
108 .ok_or_else(|| VmError::Other("ELF read overflow".to_owned()))?;
109 let slice = bytes
110 .get(offset..end)

Callers 1

parseMethod · 0.70

Calls 1

getMethod · 0.80

Tested by

no test coverage detected