diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-07 15:15:08 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-07 15:15:08 +0200 |
commit | 899cee8185d06c7fe9b08e6b1a846cd6bc4363e1 (patch) | |
tree | 0ac90e5f3a61d166845e5c0d03e2182ba6cbb921 /Kernel/KBuffer.h | |
parent | c69035c630178459e5a518fb6ef843eb01b8e661 (diff) | |
download | serenity-899cee8185d06c7fe9b08e6b1a846cd6bc4363e1.zip |
Kernel: Make KBuffer::try_create_with_size() return KResultOr
This allows us to use TRY() in a lot of new places.
Diffstat (limited to 'Kernel/KBuffer.h')
-rw-r--r-- | Kernel/KBuffer.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Kernel/KBuffer.h b/Kernel/KBuffer.h index e3e005db1d..7ac17dbe96 100644 --- a/Kernel/KBuffer.h +++ b/Kernel/KBuffer.h @@ -106,12 +106,12 @@ public: { } - [[nodiscard]] static OwnPtr<KBuffer> try_create_with_size(size_t size, Memory::Region::Access access = Memory::Region::Access::ReadWrite, StringView name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve) + static KResultOr<NonnullOwnPtr<KBuffer>> try_create_with_size(size_t size, Memory::Region::Access access = Memory::Region::Access::ReadWrite, StringView name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve) { auto impl = KBufferImpl::try_create_with_size(size, access, name, strategy); if (!impl) - return {}; - return adopt_own_if_nonnull(new (nothrow) KBuffer(impl.release_nonnull())); + return ENOMEM; + return adopt_nonnull_own_or_enomem(new (nothrow) KBuffer(impl.release_nonnull())); } [[nodiscard]] static OwnPtr<KBuffer> try_create_with_bytes(ReadonlyBytes bytes, Memory::Region::Access access = Memory::Region::Access::ReadWrite, StringView name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve) |