mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
AK: Turn ByteBuffer into a value type
Previously ByteBuffer would internally hold a RefPtr to the byte buffer and would behave like a reference type, i.e. copying a ByteBuffer would not create a duplicate byte buffer, but rather two objects which refer to the same internal buffer. This also changes ByteBuffer so that it has some internal capacity much like the Vector<T> type. Unlike Vector<T> however a byte buffer's data may be uninitialized. With this commit ByteBuffer makes use of the kmalloc_good_size() API to pick an optimal allocation size for its internal buffer.
This commit is contained in:
parent
f0fa51773a
commit
fcaf98361f
Notes:
sideshowbarker
2024-07-18 18:01:58 +09:00
Author: https://github.com/gunnarbeutner
Commit: fcaf98361f
Pull-request: https://github.com/SerenityOS/serenity/pull/7151
Reviewed-by: https://github.com/alimpfard
9 changed files with 176 additions and 236 deletions
|
@ -57,7 +57,7 @@ static bool test_single(const Testcase& testcase)
|
|||
// Setup
|
||||
ByteBuffer actual = ByteBuffer::create_uninitialized(SANDBOX_CANARY_SIZE + testcase.dest_n + SANDBOX_CANARY_SIZE);
|
||||
fill_with_random(actual.data(), actual.size());
|
||||
ByteBuffer expected = actual.isolated_copy();
|
||||
ByteBuffer expected = actual;
|
||||
VERIFY(actual.offset_pointer(0) != expected.offset_pointer(0));
|
||||
actual.overwrite(SANDBOX_CANARY_SIZE, testcase.dest, testcase.dest_n);
|
||||
expected.overwrite(SANDBOX_CANARY_SIZE, testcase.dest_expected, testcase.dest_expected_n);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue