1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:07:35 +00:00

AK/ByteBuffer+Everywhere: Handle errors in ByteBuffer::slice()

This commit is contained in:
Matthias Zimmerman 2022-06-13 05:20:42 -07:00 committed by Linus Groh
parent c0486f93d4
commit c10d48b72c
12 changed files with 45 additions and 34 deletions

View file

@ -134,13 +134,12 @@ public:
[[nodiscard]] void* end_pointer() { return data() + m_size; }
[[nodiscard]] void const* end_pointer() const { return data() + m_size; }
// FIXME: Make this function handle failures too.
[[nodiscard]] ByteBuffer slice(size_t offset, size_t size) const
[[nodiscard]] ErrorOr<ByteBuffer> slice(size_t offset, size_t size) const
{
// I cannot hand you a slice I don't have
VERIFY(offset + size <= this->size());
return copy(offset_pointer(offset), size).release_value();
return copy(offset_pointer(offset), size);
}
void clear()