kernel: Fix AddressSpace's move assignment operator
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-07-09 20:43:03 +02:00
parent c599251d2a
commit ae0cd155c3
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 11 additions and 2 deletions

View File

@ -70,11 +70,14 @@ AddressSpace& AddressSpace::operator=(AddressSpace&& other)
if (&other == this) return *this;
m_regions.consume([](VMRegion* region) { delete region; });
MMU::delete_userspace_page_directory(m_directory);
if (m_directory) MMU::delete_userspace_page_directory(m_directory);
m_regions = other.m_regions;
m_directory = other.m_directory;
other.m_regions.reset();
other.m_directory = nullptr;
return *this;
}
@ -215,5 +218,5 @@ Result<VMRegion*> AddressSpace::split_region(VMRegion* parent, u64 boundary)
AddressSpace::~AddressSpace()
{
m_regions.consume([](VMRegion* region) { delete region; });
MMU::delete_userspace_page_directory(m_directory);
if (m_directory) MMU::delete_userspace_page_directory(m_directory);
}

View File

@ -251,6 +251,12 @@ template <typename T> class LinkedList
return { nullptr, *this };
}
void reset()
{
m_start_node = m_end_node = nullptr;
m_count = 0;
}
private:
Node* m_start_node = nullptr;
Node* m_end_node = nullptr;