summaryrefslogtreecommitdiff
path: root/crates/alloc_buddy/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/alloc_buddy/src/lib.rs')
-rw-r--r--crates/alloc_buddy/src/lib.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/crates/alloc_buddy/src/lib.rs b/crates/alloc_buddy/src/lib.rs
index c890e79..fc5d245 100644
--- a/crates/alloc_buddy/src/lib.rs
+++ b/crates/alloc_buddy/src/lib.rs
@@ -369,6 +369,19 @@ impl<
self.free_list(size_class).push(ptr);
}
+ /// Returns a `Debug` that prints the free lists of the allocator.
+ pub fn debug_free_lists(&self) -> impl '_ + fmt::Debug {
+ debug(|fmt| {
+ fmt.debug_list()
+ .entries((0..SIZE_CLASS_COUNT).map(|size_class| {
+ // SAFETY: The free lists are kept valid, and the range of size classes is
+ // necessarily in-bounds.
+ unsafe { FreeList::from_sentinel(self.free_list_sentinels.add(size_class)) }
+ }))
+ .finish()
+ })
+ }
+
/// Returns the free list with the given size class.
#[requires(size_class < SIZE_CLASS_COUNT)]
fn free_list(&mut self, size_class: usize) -> FreeList {
@@ -411,20 +424,7 @@ impl<
{
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("BuddyAllocator")
- .field(
- "free_lists",
- &debug(|fmt| {
- fmt.debug_list()
- .entries((0..SIZE_CLASS_COUNT).map(|size_class| {
- // SAFETY: The free lists are kept valid, and the range of size classes is
- // necessarily in-bounds.
- unsafe {
- FreeList::from_sentinel(self.free_list_sentinels.add(size_class))
- }
- }))
- .finish()
- }),
- )
+ .field("free_lists", &self.debug_free_lists())
.field(
"trees",
&debug(|fmt| {