| 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>) { |