From c847b1e2a88dee08ad8813d334d6cf0e4df6ab94 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Sun, 17 Jul 2022 13:25:34 +0200 Subject: [PATCH] Implement FrameAllocator for mutable refs of impls. --- src/allocator/frame/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/allocator/frame/mod.rs b/src/allocator/frame/mod.rs index 5b6898a236..99c9d3215c 100644 --- a/src/allocator/frame/mod.rs +++ b/src/allocator/frame/mod.rs @@ -20,6 +20,7 @@ impl FrameCount { } } +#[derive(Debug)] pub struct FrameUsage { used: FrameCount, total: FrameCount, @@ -58,3 +59,21 @@ pub trait FrameAllocator { unsafe fn usage(&self) -> FrameUsage; } + +impl FrameAllocator for &mut T where T: FrameAllocator { + unsafe fn allocate(&mut self, count: FrameCount) -> Option { + T::allocate(self, count) + } + unsafe fn free(&mut self, address: PhysicalAddress, count: FrameCount) { + T::free(self, address, count) + } + unsafe fn allocate_one(&mut self) -> Option { + T::allocate_one(self) + } + unsafe fn free_one(&mut self, address: PhysicalAddress) { + T::free_one(self, address) + } + unsafe fn usage(&self) -> FrameUsage { + T::usage(self) + } +}