mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:58:13 +00:00
AK: Use kmalloc_array() where appropriate
This commit is contained in:
parent
2189524cb3
commit
3609ac4cf9
2 changed files with 3 additions and 3 deletions
|
@ -20,7 +20,7 @@ public:
|
||||||
: m_size(size)
|
: m_size(size)
|
||||||
{
|
{
|
||||||
if (m_size != 0) {
|
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)
|
for (size_t i = 0; i < m_size; ++i)
|
||||||
new (&m_elements[i]) T();
|
new (&m_elements[i]) T();
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public:
|
||||||
: m_size(other.m_size)
|
: m_size(other.m_size)
|
||||||
{
|
{
|
||||||
if (m_size != 0) {
|
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)
|
for (size_t i = 0; i < m_size; ++i)
|
||||||
new (&m_elements[i]) T(other[i]);
|
new (&m_elements[i]) T(other[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -623,7 +623,7 @@ public:
|
||||||
if (m_capacity >= needed_capacity)
|
if (m_capacity >= needed_capacity)
|
||||||
return true;
|
return true;
|
||||||
size_t new_capacity = kmalloc_good_size(needed_capacity * sizeof(StorageType)) / sizeof(StorageType);
|
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)
|
if (new_buffer == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue