From 53d65fb3930167bfcff5bb1b0d5501ea68136362 Mon Sep 17 00:00:00 2001 From: Amelia Coutard Date: Sat, 7 May 2022 17:29:38 +0200 Subject: [PATCH] Added a special case for deallocating a 0-sized block, and remove the unimplemented `mark_as_used` --- src/paging.cpp | 2 +- src/paging.hpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/paging.cpp b/src/paging.cpp index f3b45cd..d841509 100644 --- a/src/paging.cpp +++ b/src/paging.cpp @@ -18,7 +18,6 @@ void os::paging::page_allocator::print_all() const { } } -// void os::paging::page_allocator::mark_as_used(block b); os::paging::page_allocator::block os::paging::page_allocator::allocate(std::uint64_t count) { for (auto it = begin(); it != end(); it = it->next) { if (count == it->size) { @@ -38,6 +37,7 @@ os::paging::page_allocator::block os::paging::page_allocator::allocate(std::uint return { .ptr = nullptr, .size = 0 }; } void os::paging::page_allocator::deallocate(block b) { + if (b.size == 0) { return; } const phys_ptr b_it{b.ptr.get_phys_addr()}; auto it = begin(); while (it != end() && it < b_it) { it = it->next; } diff --git a/src/paging.hpp b/src/paging.hpp index 779e4cc..76024d7 100644 --- a/src/paging.hpp +++ b/src/paging.hpp @@ -156,7 +156,6 @@ public: page_allocator(phys_ptr one_past_end_page); void print_all() const; - void mark_as_used(block b); block allocate(std::uint64_t page_count); void deallocate(block b); -- 2.47.0