1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:24:57 +00:00

LibCore: Use ErrorOr<T> in Core::AnonymousBuffer

This commit is contained in:
Andreas Kling 2021-11-06 01:20:51 +01:00
parent c4edb9f6c2
commit e2eabb4132
15 changed files with 56 additions and 53 deletions

View file

@ -25,11 +25,12 @@ Optional<DecodedImage> Client::decode_image(const ReadonlyBytes& encoded_data)
if (encoded_data.is_empty())
return {};
auto encoded_buffer = Core::AnonymousBuffer::create_with_size(encoded_data.size());
if (!encoded_buffer.is_valid()) {
auto encoded_buffer_or_error = Core::AnonymousBuffer::create_with_size(encoded_data.size());
if (encoded_buffer_or_error.is_error()) {
dbgln("Could not allocate encoded buffer");
return {};
}
auto encoded_buffer = encoded_buffer_or_error.release_value();
memcpy(encoded_buffer.data<void>(), encoded_data.data(), encoded_data.size());
auto response_or_error = try_decode_image(move(encoded_buffer));