mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
Kernel: Make Process::allocate_region*() return KResultOr<Region*>
This allows region allocation to return specific errors and we don't have to assume every failure is an ENOMEM.
This commit is contained in:
parent
7899e14e72
commit
64b0d89335
10 changed files with 70 additions and 79 deletions
|
@ -94,10 +94,10 @@ void* SharedBuffer::ref_for_process_and_get_address(Process& process)
|
|||
for (auto& ref : m_refs) {
|
||||
if (ref.pid == process.pid()) {
|
||||
if (!ref.region) {
|
||||
auto* region = process.allocate_region_with_vmobject(VirtualAddress(), size(), m_vmobject, 0, "SharedBuffer", PROT_READ | (m_writable ? PROT_WRITE : 0), true);
|
||||
if (!region)
|
||||
return (void*)-ENOMEM;
|
||||
ref.region = region;
|
||||
auto region_or_error = process.allocate_region_with_vmobject(VirtualAddress(), size(), m_vmobject, 0, "SharedBuffer", PROT_READ | (m_writable ? PROT_WRITE : 0), true);
|
||||
if (region_or_error.is_error())
|
||||
return (void*)region_or_error.error().error();
|
||||
ref.region = region_or_error.value();
|
||||
}
|
||||
ref.count++;
|
||||
m_total_refs++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue