summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-07 22:34:29 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-08 00:03:45 +0200
commit3609ac4cf9af0ec38b464e652d9dc16427f85c04 (patch)
tree5437396144fbd1a48518f6df04cdd2f6194dfdcf /AK
parent2189524cb3ca4a12276007c6634d44170e2215ca (diff)
downloadserenity-3609ac4cf9af0ec38b464e652d9dc16427f85c04.zip
AK: Use kmalloc_array() where appropriate
Diffstat (limited to 'AK')
-rw-r--r--AK/FixedArray.h4
-rw-r--r--AK/Vector.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/AK/FixedArray.h b/AK/FixedArray.h
index b32ccd2e84..c2d22512ca 100644
--- a/AK/FixedArray.h
+++ b/AK/FixedArray.h
@@ -20,7 +20,7 @@ public:
: m_size(size)
{
if (m_size != 0) {
- m_elements = (T*)kmalloc(sizeof(T) * m_size);
+ m_elements = static_cast<T*>(kmalloc_array(m_size, sizeof(T)));
for (size_t i = 0; i < m_size; ++i)
new (&m_elements[i]) T();
}
@@ -34,7 +34,7 @@ public:
: m_size(other.m_size)
{
if (m_size != 0) {
- m_elements = (T*)kmalloc(sizeof(T) * m_size);
+ m_elements = static_cast<T*>(kmalloc_array(m_size, sizeof(T)));
for (size_t i = 0; i < m_size; ++i)
new (&m_elements[i]) T(other[i]);
}
diff --git a/AK/Vector.h b/AK/Vector.h
index 88d1348e84..f13fb1198a 100644
--- a/AK/Vector.h
+++ b/AK/Vector.h
@@ -623,7 +623,7 @@ public:
if (m_capacity >= needed_capacity)
return true;
size_t new_capacity = kmalloc_good_size(needed_capacity * sizeof(StorageType)) / sizeof(StorageType);
- auto* new_buffer = (StorageType*)kmalloc(new_capacity * sizeof(StorageType));
+ auto* new_buffer = static_cast<StorageType*>(kmalloc_array(new_capacity, sizeof(StorageType)));
if (new_buffer == nullptr)
return false;