summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-05-31 00:31:46 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-05-31 14:49:00 +0430
commit5f18cf75c5d660873f840512f2fe55d4e239e238 (patch)
treef980bd886c4369a237899cddaf16458416c6e1b9 /Userland/Libraries
parentdc54a0fbd399923ca0c3db1ffd34c63158ecd7d5 (diff)
downloadserenity-5f18cf75c5d660873f840512f2fe55d4e239e238.zip
AK: Replace ByteBuffer::grow with resize()/ensure_capacity()
Previously ByteBuffer::grow() behaved like Vector<T>::resize(). However the function name was somewhat ambiguous - and so this patch updates ByteBuffer to behave more like Vector<T> by replacing grow() with resize() and adding an ensure_capacity() method. This also lets the user change the buffer's capacity without affecting the size which was not previously possible. Additionally this patch makes the capacity() method public (again).
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp3
-rw-r--r--Userland/Libraries/LibTLS/HandshakeClient.cpp3
-rw-r--r--Userland/Libraries/LibTLS/TLSPacketBuilder.h2
-rw-r--r--Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h2
4 files changed, 4 insertions, 6 deletions
diff --git a/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp b/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp
index a4beb68e45..11c68e1538 100644
--- a/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp
+++ b/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp
@@ -165,8 +165,7 @@ UnsignedBigInteger random_number(const UnsignedBigInteger& min, const UnsignedBi
UnsignedBigInteger base;
auto size = range.trimmed_length() * sizeof(u32) + 2;
// "+2" is intentional (see below).
- ByteBuffer buffer;
- buffer.grow(size);
+ auto buffer = ByteBuffer::create_uninitialized(size);
auto* buf = buffer.data();
fill_with_random(buf, size);
diff --git a/Userland/Libraries/LibTLS/HandshakeClient.cpp b/Userland/Libraries/LibTLS/HandshakeClient.cpp
index 949121c891..55521d658b 100644
--- a/Userland/Libraries/LibTLS/HandshakeClient.cpp
+++ b/Userland/Libraries/LibTLS/HandshakeClient.cpp
@@ -117,8 +117,7 @@ bool TLSv12::compute_master_secret_from_pre_master_secret(size_t length)
return false;
}
- m_context.master_key.clear();
- m_context.master_key.grow(length);
+ m_context.master_key.resize(length);
pseudorandom_function(
m_context.master_key,
diff --git a/Userland/Libraries/LibTLS/TLSPacketBuilder.h b/Userland/Libraries/LibTLS/TLSPacketBuilder.h
index dfc6cf7394..955caa0492 100644
--- a/Userland/Libraries/LibTLS/TLSPacketBuilder.h
+++ b/Userland/Libraries/LibTLS/TLSPacketBuilder.h
@@ -75,7 +75,7 @@ public:
m_current_length += bytes;
if (m_packet_data.size() < m_current_length) {
- m_packet_data.grow(m_current_length);
+ m_packet_data.resize(m_current_length);
}
m_packet_data.overwrite(old_length, data, bytes);
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h
index 4646df4738..98db12d9ab 100644
--- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h
+++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h
@@ -332,7 +332,7 @@ public:
if (m_type.limits().max().value_or(new_size) < new_size)
return false;
auto previous_size = m_size;
- m_data.grow(new_size);
+ m_data.resize(new_size);
m_size = new_size;
// The spec requires that we zero out everything on grow
__builtin_memset(m_data.offset_pointer(previous_size), 0, size_to_grow);