mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
AK: Add an overwrite API to ByteBuffer
Since ByteBuffer is a Buffer, it should allow us to overwrite parts of it that we have allocated. This comes in useful in handling unsequenced writes like handling fragmented ip packets :^)
This commit is contained in:
parent
3fae4cb054
commit
df7062aac5
1 changed files with 7 additions and 0 deletions
|
@ -216,6 +216,13 @@ public:
|
|||
__builtin_memcpy(this->data() + old_size, data, data_size);
|
||||
}
|
||||
|
||||
void overwrite(size_t offset, const void* data, size_t data_size)
|
||||
{
|
||||
// make sure we're not told to write past the end
|
||||
ASSERT(offset + data_size < size());
|
||||
__builtin_memcpy(this->data() + offset, data, data_size);
|
||||
}
|
||||
|
||||
private:
|
||||
explicit ByteBuffer(RefPtr<ByteBufferImpl>&& impl)
|
||||
: m_impl(move(impl))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue