summaryrefslogtreecommitdiff
path: root/crates/alloc_buddy/src/tree.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/alloc_buddy/src/tree.rs')
-rw-r--r--crates/alloc_buddy/src/tree.rs51
1 files changed, 1 insertions, 50 deletions
diff --git a/crates/alloc_buddy/src/tree.rs b/crates/alloc_buddy/src/tree.rs
index 787af21..e04605b 100644
--- a/crates/alloc_buddy/src/tree.rs
+++ b/crates/alloc_buddy/src/tree.rs
@@ -1,6 +1,6 @@
use crate::bitset::{Bitset, SubregionStatus, UnexpectedBitsetState};
use contracts::requires;
-use core::{fmt, ptr::NonNull};
+use core::ptr::NonNull;
/// A single region of the allocator. See the comment on the `crate::allocators::buddy` module for
/// more information.
@@ -97,53 +97,4 @@ impl<const PAGE_SIZE: usize, const PAGE_SIZE_BITS: usize> Tree<PAGE_SIZE, PAGE_S
let tree_addr_hi = tree_addr_lo + (PAGE_SIZE << self.size_class);
(tree_addr_lo..tree_addr_hi).contains(&addr)
}
-
- /// Formats the region of the bitset corresponding to this tree.
- pub fn debug_bitset<'a>(&'a self, bitset: &'a Bitset) -> impl 'a + fmt::Debug {
- struct BitsetSlice<'a, const PAGE_SIZE: usize, const PAGE_SIZE_BITS: usize>(
- &'a Tree<PAGE_SIZE, PAGE_SIZE_BITS>,
- &'a Bitset,
- usize,
- );
-
- impl<'a, const PAGE_SIZE: usize, const PAGE_SIZE_BITS: usize> fmt::Debug
- for BitsetSlice<'a, PAGE_SIZE, PAGE_SIZE_BITS>
- {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- for i in 0..(1 << (self.0.size_class - self.2)) {
- let offset_bytes = i << (PAGE_SIZE_BITS + self.2);
- let bit = match self.0.bitset_get(self.1, self.2, offset_bytes) {
- SubregionStatus::NotInFreeList => '0',
- SubregionStatus::InFreeList => '1',
- };
- write!(fmt, "{}", bit)?;
- for _ in 0..(1 << self.2) - 1 {
- write!(fmt, " ")?;
- }
- }
- Ok(())
- }
- }
-
- struct BitsetTree<'a, const PAGE_SIZE: usize, const PAGE_SIZE_BITS: usize>(
- &'a Tree<PAGE_SIZE, PAGE_SIZE_BITS>,
- &'a Bitset,
- );
-
- impl<'a, const PAGE_SIZE: usize, const PAGE_SIZE_BITS: usize> fmt::Debug
- for BitsetTree<'a, PAGE_SIZE, PAGE_SIZE_BITS>
- {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- fmt.debug_list()
- .entries(
- (0..=self.0.size_class)
- .rev()
- .map(|size_class| BitsetSlice(self.0, self.1, size_class)),
- )
- .finish()
- }
- }
-
- BitsetTree(self, bitset)
- }
}