1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:58:11 +00:00

LibJS: Allow ArrayBuffer to not own its backing data buffer as well

This is implemented as a ByteBuffer* in a variant, so its size should
only be increased by an index.
This commit is contained in:
Ali Mohammad Pur 2021-05-17 21:39:31 +04:30 committed by Ali Mohammad Pur
parent 3926eab3b7
commit 4fd43a8f96
2 changed files with 27 additions and 4 deletions

View file

@ -19,6 +19,11 @@ ArrayBuffer* ArrayBuffer::create(GlobalObject& global_object, ByteBuffer& buffer
return global_object.heap().allocate<ArrayBuffer>(global_object, buffer, *global_object.array_buffer_prototype());
}
ArrayBuffer* ArrayBuffer::create(GlobalObject& global_object, ByteBuffer* buffer)
{
return global_object.heap().allocate<ArrayBuffer>(global_object, buffer, *global_object.array_buffer_prototype());
}
ArrayBuffer::ArrayBuffer(size_t byte_size, Object& prototype)
: Object(prototype)
, m_buffer(ByteBuffer::create_zeroed(byte_size))
@ -31,6 +36,12 @@ ArrayBuffer::ArrayBuffer(ByteBuffer& buffer, Object& prototype)
{
}
ArrayBuffer::ArrayBuffer(ByteBuffer* buffer, Object& prototype)
: Object(prototype)
, m_buffer(buffer)
{
}
ArrayBuffer::~ArrayBuffer()
{
}