summaryrefslogtreecommitdiff
path: root/Kernel/VM/Region.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-27 14:19:07 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-27 14:25:42 +0200
commit7f9a33dba17df3e554aadac00c37e246780ba860 (patch)
tree2bbba33eebd7acd73db6b7d73dbd579b3a3bf7f0 /Kernel/VM/Region.cpp
parent7a7f6a24e9490ab57c2b3515c971548fa58e9cdf (diff)
downloadserenity-7f9a33dba17df3e554aadac00c37e246780ba860.zip
Kernel: Make Region single-owner instead of ref-counted
This simplifies the ownership model and makes Region easier to reason about. Userspace Regions are now primarily kept by Process::m_regions. Kernel Regions are kept in various OwnPtr<Regions>'s. Regions now only ever get unmapped when they are destroyed.
Diffstat (limited to 'Kernel/VM/Region.cpp')
-rw-r--r--Kernel/VM/Region.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp
index 6e778e5197..2a3345b480 100644
--- a/Kernel/VM/Region.cpp
+++ b/Kernel/VM/Region.cpp
@@ -50,7 +50,7 @@ Region::~Region()
MM.unregister_region(*this);
}
-NonnullRefPtr<Region> Region::clone()
+NonnullOwnPtr<Region> Region::clone()
{
ASSERT(current);
@@ -123,30 +123,30 @@ size_t Region::amount_shared() const
return bytes;
}
-NonnullRefPtr<Region> Region::create_user_accessible(const Range& range, const StringView& name, u8 access, bool cow)
+NonnullOwnPtr<Region> Region::create_user_accessible(const Range& range, const StringView& name, u8 access, bool cow)
{
- auto region = adopt(*new Region(range, name, access, cow));
+ auto region = make<Region>(range, name, access, cow);
region->m_user_accessible = true;
return region;
}
-NonnullRefPtr<Region> Region::create_user_accessible(const Range& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const StringView& name, u8 access, bool cow)
+NonnullOwnPtr<Region> Region::create_user_accessible(const Range& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const StringView& name, u8 access, bool cow)
{
- auto region = adopt(*new Region(range, move(vmobject), offset_in_vmobject, name, access, cow));
+ auto region = make<Region>(range, move(vmobject), offset_in_vmobject, name, access, cow);
region->m_user_accessible = true;
return region;
}
-NonnullRefPtr<Region> Region::create_user_accessible(const Range& range, NonnullRefPtr<Inode> inode, const StringView& name, u8 access, bool cow)
+NonnullOwnPtr<Region> Region::create_user_accessible(const Range& range, NonnullRefPtr<Inode> inode, const StringView& name, u8 access, bool cow)
{
- auto region = adopt(*new Region(range, move(inode), name, access, cow));
+ auto region = make<Region>(range, move(inode), name, access, cow);
region->m_user_accessible = true;
return region;
}
-NonnullRefPtr<Region> Region::create_kernel_only(const Range& range, const StringView& name, u8 access, bool cow)
+NonnullOwnPtr<Region> Region::create_kernel_only(const Range& range, const StringView& name, u8 access, bool cow)
{
- auto region = adopt(*new Region(range, name, access, cow));
+ auto region = make<Region>(range, name, access, cow);
region->m_user_accessible = false;
return region;
}