MCPcopy Create free account
hub / github.com/LibertyOS-Development/kernel / dealloc

Method dealloc

src/allocator/fixedsize.rs:92–117  ·  view source on GitHub ↗
(&self, ptr: *mut u8, layout: Layout)

Source from the content-addressed store, hash-verified

90 }
91
92 unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)
93 {
94 let mut allocator = self.lock();
95 match lsidx(&layout)
96 {
97 Some(index) =>
98 {
99 let new_node = ListNode
100 {
101 next: allocator.listheads[index].take(),
102 };
103
104 // Verify that the block has a size and an alignment.
105 assert!(mem::size_of::<ListNode>() <= BLKSIZES[index]);
106 assert!(mem::align_of::<ListNode>() <= BLKSIZES[index]);
107 let new_node_ptr = ptr as *mut ListNode;
108 new_node_ptr.write(new_node);
109 allocator.listheads[index] = Some(&mut *new_node_ptr);
110 }
111 None =>
112 {
113 let ptr = NonNull::new(ptr).unwrap();
114 allocator.fballoc.deallocate(ptr, layout);
115 }
116 }
117 }
118}

Callers

nothing calls this directly

Calls 3

lsidxFunction · 0.85
lockMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected