From 3609ac4cf9af0ec38b464e652d9dc16427f85c04 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 7 Aug 2021 22:34:29 +0200 Subject: AK: Use kmalloc_array() where appropriate --- AK/FixedArray.h | 4 ++-- AK/Vector.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'AK') 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(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(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(kmalloc_array(new_capacity, sizeof(StorageType))); if (new_buffer == nullptr) return false; -- cgit v1.2.3