Skip to content

Commit

Permalink
[fix] improve dealloc_pages
Browse files Browse the repository at this point in the history
  • Loading branch information
hky1999 committed Dec 12, 2024
1 parent 444d7ee commit acd8c18
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ impl<const PAGE_SIZE: usize> PageAllocator for BitmapPageAllocator<PAGE_SIZE> {
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;
}
}
Expand Down

0 comments on commit acd8c18

Please sign in to comment.