add some more code
This commit is contained in:
parent
9747d94ccc
commit
51300ffea4
1 changed files with 20 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
#![no_std]
|
||||
|
||||
use tinyptr::ptr::MutPtr;
|
||||
use tinyptr::ptr::{MutPtr, NonNull};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ListNode<const BASE: usize> {
|
||||
|
@ -8,3 +8,22 @@ pub struct ListNode<const BASE: usize> {
|
|||
pub size: u16
|
||||
}
|
||||
|
||||
impl<const BASE: usize> ListNode<BASE> {
|
||||
pub unsafe fn next(&mut self) -> Option<&mut Self> {
|
||||
if self.next.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&mut *(self.next.wide()))
|
||||
}
|
||||
}
|
||||
pub unsafe fn link_next(&mut self, block: NonNull<Self, BASE>) {
|
||||
(*block.as_ptr().wide()).next = self.next;
|
||||
self.next = block.as_ptr();
|
||||
}
|
||||
pub unsafe fn unlink_next(&mut self) {
|
||||
if self.next.is_null() {
|
||||
return;
|
||||
}
|
||||
self.next = (*self.next.wide()).next;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue