mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-25 22:14:37 +00:00
memory: Refactor SwapPT class
This commit is contained in:
parent
b6006e379d
commit
29896bb0a4
@ -31,12 +31,19 @@ namespace Memory
|
||||
private:
|
||||
PageTable *Replace = nullptr;
|
||||
PageTable *Restore = nullptr;
|
||||
bool Ignore;
|
||||
|
||||
public:
|
||||
SwapPT(PageTable *ReplaceWith,
|
||||
PageTable *RestoreWith = nullptr)
|
||||
: Replace(ReplaceWith)
|
||||
SwapPT(auto ReplaceWith,
|
||||
auto _RestoreWith = nullptr)
|
||||
: Replace((PageTable *)ReplaceWith)
|
||||
{
|
||||
PageTable *RestoreWith = (PageTable *)_RestoreWith;
|
||||
|
||||
this->Ignore = Replace == RestoreWith;
|
||||
if (this->Ignore)
|
||||
return;
|
||||
|
||||
if (RestoreWith)
|
||||
Restore = RestoreWith;
|
||||
else
|
||||
@ -45,7 +52,13 @@ namespace Memory
|
||||
Replace->Update();
|
||||
}
|
||||
|
||||
~SwapPT() { Restore->Update(); }
|
||||
~SwapPT()
|
||||
{
|
||||
if (this->Ignore)
|
||||
return;
|
||||
|
||||
Restore->Update();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user