mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:17:35 +00:00
Kernel: Make it possible for KBufferBuilder creation to fail
This patch adds KBufferBuilder::try_create() and treats it like anything else that can fail. And so, failure to allocate the initial internal buffer of the builder will now propagate an ENOMEM to the caller. :^)
This commit is contained in:
parent
be613b9ef6
commit
300402cc14
9 changed files with 30 additions and 13 deletions
|
@ -6,18 +6,22 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/KBuffer.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class KBufferBuilder {
|
||||
AK_MAKE_NONCOPYABLE(KBufferBuilder);
|
||||
|
||||
public:
|
||||
using OutputType = KBuffer;
|
||||
|
||||
KBufferBuilder();
|
||||
static KResultOr<KBufferBuilder> try_create();
|
||||
|
||||
KBufferBuilder(KBufferBuilder&&) = default;
|
||||
KBufferBuilder& operator=(KBufferBuilder&&) = default;
|
||||
~KBufferBuilder() = default;
|
||||
|
||||
KResult append(const StringView&);
|
||||
|
@ -48,6 +52,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
explicit KBufferBuilder(NonnullOwnPtr<KBuffer>);
|
||||
|
||||
bool check_expand(size_t);
|
||||
u8* insertion_ptr()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue