mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Use kmalloc_array() where appropriate
This commit is contained in:
parent
2189524cb3
commit
3609ac4cf9
Notes:
sideshowbarker
2024-07-18 07:17:52 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/3609ac4cf9a
2 changed files with 3 additions and 3 deletions
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue