MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / new_memory

Method new_memory

tests/all/memory_creator.rs:100–122  ·  view source on GitHub ↗
(
            &self,
            ty: MemoryType,
            minimum: usize,
            maximum: Option<usize>,
            reserved_size: Option<usize>,
            guard_size: usize,
        )

Source from the content-addressed store, hash-verified

98
99 unsafe impl MemoryCreator for CustomMemoryCreator {
100 fn new_memory(
101 &self,
102 ty: MemoryType,
103 minimum: usize,
104 maximum: Option<usize>,
105 reserved_size: Option<usize>,
106 guard_size: usize,
107 ) -> Result<Box<dyn LinearMemory>, String> {
108 assert_eq!(guard_size, 0);
109 assert_eq!(reserved_size, Some(0));
110 assert!(!ty.is_64());
111 unsafe {
112 // Cap the maximum at 10MiB to reduce the virtual memory
113 // allocated by this test to execute on 32-bit platforms.
114 let mem = Box::new(CustomMemory::new(
115 minimum,
116 maximum.unwrap_or(10 << 20),
117 self.num_total_bytes.clone(),
118 ));
119 *self.num_created_memories.lock().unwrap() += 1;
120 Ok(mem)
121 }
122 }
123 }
124
125 fn config() -> (Store<()>, Arc<CustomMemoryCreator>) {

Callers

nothing calls this directly

Calls 5

OkFunction · 0.85
newFunction · 0.50
cloneMethod · 0.45
unwrapMethod · 0.45
lockMethod · 0.45

Tested by

no test coverage detected