mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
Kernel: Convert KBuffer::copy() => KBuffer::try_copy()
This was a weird KBuffer API that assumed failure was impossible. This patch converts it to a modern KResultOr<NonnullOwnPtr<KBuffer>> API and updates the two clients to the new style.
This commit is contained in:
parent
250b52d6e5
commit
b300f9aa2f
5 changed files with 49 additions and 28 deletions
|
@ -122,9 +122,12 @@ public:
|
|||
return adopt_nonnull_own_or_enomem(new (nothrow) KBuffer(impl.release_nonnull()));
|
||||
}
|
||||
|
||||
[[nodiscard]] static KBuffer copy(const void* data, size_t size, Memory::Region::Access access = Memory::Region::Access::ReadWrite, StringView name = "KBuffer")
|
||||
static KResultOr<NonnullOwnPtr<KBuffer>> try_copy(const void* data, size_t size, Memory::Region::Access access = Memory::Region::Access::ReadWrite, StringView name = "KBuffer")
|
||||
{
|
||||
return KBuffer(KBufferImpl::copy(data, size, access, name));
|
||||
auto impl = KBufferImpl::copy(data, size, access, name);
|
||||
if (!impl)
|
||||
return ENOMEM;
|
||||
return adopt_nonnull_own_or_enomem(new (nothrow) KBuffer(impl.release_nonnull()));
|
||||
}
|
||||
|
||||
[[nodiscard]] bool is_null() const { return !m_impl; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue