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

Method add_freergn

src/allocator/lnls.rs:60–72  ·  view source on GitHub ↗

Add specified memreg to front of the list:

(&mut self, addr: usize, size: usize)

Source from the content-addressed store, hash-verified

58
59 // Add specified memreg to front of the list:
60 unsafe fn add_freergn(&mut self, addr: usize, size: usize)
61 {
62 // Verify that freed region is able to hold ListNode:
63 assert_eq!(alignup(addr, mem::align_of::<ListNode>()), addr);
64 assert!(size >= mem::size_of::<ListNode>());
65
66 // Create new list-node, append to start of list:
67 let mut node = ListNode::new(size);
68 node.next = self.head.next.take();
69 let node_ptr = addr as *mut ListNode;
70 node_ptr.write(node);
71 self.head.next = Some(&mut *node_ptr)
72 }
73
74 // Locate a free region, matching the specified size and alignment, and removes said region from list:
75 // NOTE: This will return a tuple, containing the list-node, and the start address of the allocation.

Callers 3

initMethod · 0.80
allocMethod · 0.80
deallocMethod · 0.80

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected