(&self, layout: Layout)
| 133 | |
| 134 | unsafe impl GlobalAlloc for Locked<LinkedListAllocator> { |
| 135 | unsafe fn alloc(&self, layout: Layout) -> *mut u8 { |
| 136 | // perform layout adjustments |
| 137 | let (size, align) = LinkedListAllocator::size_align(layout); |
| 138 | let mut allocator = self.lock(); |
| 139 | |
| 140 | if let Some((region, alloc_start)) = allocator.find_region(size, align) { |
| 141 | let alloc_end = alloc_start.checked_add(size).expect("overflow"); |
| 142 | let excess_size = region.end_addr() - alloc_end; |
| 143 | if excess_size > 0 { |
| 144 | unsafe { |
| 145 | allocator.add_free_region(alloc_end, excess_size); |
| 146 | } |
| 147 | } |
| 148 | alloc_start as *mut u8 |
| 149 | } else { |
| 150 | ptr::null_mut() |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { |
| 155 | // perform layout adjustments |
nothing calls this directly
no test coverage detected