1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:08:12 +00:00

Kernel: Remove allocate_region() functions that don't take a Range

Let's force callers to provide a VM range when allocating a region.
This makes ENOMEM error handling more visible and removes implicit
VM allocation which felt a bit magical.
This commit is contained in:
Andreas Kling 2021-01-26 14:13:57 +01:00
parent d697d33fa6
commit 1e25d2b734
5 changed files with 41 additions and 25 deletions

View file

@ -150,14 +150,6 @@ KResultOr<Region*> Process::allocate_region(const Range& range, const String& na
return &add_region(move(region));
}
KResultOr<Region*> Process::allocate_region(VirtualAddress vaddr, size_t size, const String& name, int prot, AllocationStrategy strategy)
{
auto range = allocate_range(vaddr, size);
if (!range.is_valid())
return ENOMEM;
return allocate_region(range, name, prot, strategy);
}
KResultOr<Region*> Process::allocate_region_with_vmobject(const Range& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const String& name, int prot, bool shared)
{
ASSERT(range.is_valid());
@ -183,14 +175,6 @@ KResultOr<Region*> Process::allocate_region_with_vmobject(const Range& range, No
return &region;
}
KResultOr<Region*> Process::allocate_region_with_vmobject(VirtualAddress vaddr, size_t size, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const String& name, int prot, bool shared)
{
auto range = allocate_range(vaddr, size);
if (!range.is_valid())
return ENOMEM;
return allocate_region_with_vmobject(range, move(vmobject), offset_in_vmobject, name, prot, shared);
}
bool Process::deallocate_region(Region& region)
{
OwnPtr<Region> region_protector;