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

Method allocate_chunk

crates/tinywasm/src/store/memory/paged.rs:46–57  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

44
45 #[inline(always)]
46 fn allocate_chunk(&self) -> Result<Box<[u8]>, crate::Trap> {
47 let mut chunk = Vec::new();
48 match chunk.try_reserve_exact(self.chunk_size) {
49 Ok(()) => {}
50 Err(_) => {
51 cold_path();
52 return Err(crate::Trap::OutOfMemory);
53 }
54 }
55 chunk.resize(self.chunk_size, 0);
56 Ok(chunk.into_boxed_slice())
57 }
58
59 #[inline(always)]
60 fn chunk_mut(&mut self, chunk_idx: usize) -> Result<&mut [u8], crate::Trap> {

Callers 1

chunk_mutMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected