From: Amelia Coutard Date: Sat, 7 May 2022 15:29:38 +0000 (+0200) Subject: Added a special case for deallocating a 0-sized block, and remove the unimplemented... X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=53d65fb3930167bfcff5bb1b0d5501ea68136362;p=voyage-au-centre-des-fichiers.git Added a special case for deallocating a 0-sized block, and remove the unimplemented `mark_as_used` --- 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);