From acd8c186e4034a59d0a7179ab51fd97b7377d651 Mon Sep 17 00:00:00 2001 From: hky1999 <976929993@qq.com> Date: Thu, 12 Dec 2024 13:39:12 +0800 Subject: [PATCH] [fix] improve dealloc_pages --- src/bitmap.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bitmap.rs b/src/bitmap.rs index fff0fe6..4f47866 100644 --- a/src/bitmap.rs +++ b/src/bitmap.rs @@ -135,11 +135,13 @@ impl PageAllocator for BitmapPageAllocator { crate::is_aligned(pos, Self::PAGE_SIZE), "pos must be aligned to PAGE_SIZE" ); - - if self - .inner - .dealloc_contiguous((pos - self.base) / PAGE_SIZE, num_pages) - { + if match num_pages.cmp(&1) { + core::cmp::Ordering::Equal => self.inner.dealloc((pos - self.base) / PAGE_SIZE), + core::cmp::Ordering::Greater => self + .inner + .dealloc_contiguous((pos - self.base) / PAGE_SIZE, num_pages), + _ => false, + } { self.used_pages -= num_pages; } }