mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:27:35 +00:00
AK: Make ByteBuffer::try_* functions return ErrorOr<void>
Same as Vector, ByteBuffer now also signals allocation failure by returning an ENOMEM Error instead of a bool, allowing us to use the TRY() and MUST() patterns.
This commit is contained in:
parent
88b6428c25
commit
a15ed8743d
20 changed files with 59 additions and 70 deletions
|
@ -349,7 +349,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
auto previous_size = m_size;
|
||||
if (!m_data.try_resize(new_size))
|
||||
if (m_data.try_resize(new_size).is_error())
|
||||
return false;
|
||||
m_size = new_size;
|
||||
// The spec requires that we zero out everything on grow
|
||||
|
|
|
@ -739,7 +739,7 @@ ParseResult<CustomSection> CustomSection::parse(InputStream& stream)
|
|||
return name.error();
|
||||
|
||||
ByteBuffer data_buffer;
|
||||
if (!data_buffer.try_resize(64))
|
||||
if (data_buffer.try_resize(64).is_error())
|
||||
return ParseError::OutOfMemory;
|
||||
|
||||
while (!stream.has_any_error() && !stream.unreliable_eof()) {
|
||||
|
@ -747,7 +747,7 @@ ParseResult<CustomSection> CustomSection::parse(InputStream& stream)
|
|||
auto size = stream.read({ buf, 16 });
|
||||
if (size == 0)
|
||||
break;
|
||||
if (!data_buffer.try_append(buf, size))
|
||||
if (data_buffer.try_append(buf, size).is_error())
|
||||
return with_eof_check(stream, ParseError::HugeAllocationRequested);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue