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:
|
private:
|
||||||
PageTable *Replace = nullptr;
|
PageTable *Replace = nullptr;
|
||||||
PageTable *Restore = nullptr;
|
PageTable *Restore = nullptr;
|
||||||
|
bool Ignore;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SwapPT(PageTable *ReplaceWith,
|
SwapPT(auto ReplaceWith,
|
||||||
PageTable *RestoreWith = nullptr)
|
auto _RestoreWith = nullptr)
|
||||||
: Replace(ReplaceWith)
|
: Replace((PageTable *)ReplaceWith)
|
||||||
{
|
{
|
||||||
|
PageTable *RestoreWith = (PageTable *)_RestoreWith;
|
||||||
|
|
||||||
|
this->Ignore = Replace == RestoreWith;
|
||||||
|
if (this->Ignore)
|
||||||
|
return;
|
||||||
|
|
||||||
if (RestoreWith)
|
if (RestoreWith)
|
||||||
Restore = RestoreWith;
|
Restore = RestoreWith;
|
||||||
else
|
else
|
||||||
@ -45,7 +52,13 @@ namespace Memory
|
|||||||
Replace->Update();
|
Replace->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
~SwapPT() { Restore->Update(); }
|
~SwapPT()
|
||||||
|
{
|
||||||
|
if (this->Ignore)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Restore->Update();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user