1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:07:34 +00:00

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.
This commit is contained in:
Andreas Kling 2019-09-27 14:19:07 +02:00
parent 7a7f6a24e9
commit 7f9a33dba1
9 changed files with 44 additions and 41 deletions

View file

@ -21,7 +21,7 @@ public:
{
auto region = MM.allocate_kernel_region(PAGE_ROUND_UP(size), "KBuffer", false, false);
ASSERT(region);
return adopt(*new KBufferImpl(*region, size));
return adopt(*new KBufferImpl(region.release_nonnull(), size));
}
static NonnullRefPtr<KBufferImpl> copy(const void* data, size_t size)
@ -43,14 +43,14 @@ public:
}
private:
explicit KBufferImpl(NonnullRefPtr<Region>&& region, size_t size)
explicit KBufferImpl(NonnullOwnPtr<Region>&& region, size_t size)
: m_size(size)
, m_region(move(region))
{
}
size_t m_size { 0 };
NonnullRefPtr<Region> m_region;
NonnullOwnPtr<Region> m_region;
};
class KBuffer {