mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-20 15:25:38 +00:00
Common: Alloc failures in HeapArray are unlikely
This commit is contained in:
parent
a89ec0eaf9
commit
dd420cbfcf
|
@ -9,8 +9,8 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <type_traits>
|
|
||||||
#include <span>
|
#include <span>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
template<typename T, std::size_t SIZE, std::size_t ALIGNMENT = 0>
|
template<typename T, std::size_t SIZE, std::size_t ALIGNMENT = 0>
|
||||||
class FixedHeapArray
|
class FixedHeapArray
|
||||||
|
@ -361,10 +361,10 @@ private:
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
m_data = static_cast<T*>(_aligned_realloc(prev_ptr, size * sizeof(T), alignment));
|
m_data = static_cast<T*>(_aligned_realloc(prev_ptr, size * sizeof(T), alignment));
|
||||||
if (!m_data)
|
if (!m_data) [[unlikely]]
|
||||||
Panic("Memory allocation failed.");
|
Panic("Memory allocation failed.");
|
||||||
#else
|
#else
|
||||||
if (posix_memalign(reinterpret_cast<void**>(&m_data), alignment, size * sizeof(T)) != 0)
|
if (posix_memalign(reinterpret_cast<void**>(&m_data), alignment, size * sizeof(T)) != 0) [[unlikely]]
|
||||||
Panic("Memory allocation failed.");
|
Panic("Memory allocation failed.");
|
||||||
|
|
||||||
if (prev_ptr)
|
if (prev_ptr)
|
||||||
|
@ -377,7 +377,7 @@ private:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_data = static_cast<T*>(std::realloc(prev_ptr, size * sizeof(T)));
|
m_data = static_cast<T*>(std::realloc(prev_ptr, size * sizeof(T)));
|
||||||
if (!m_data)
|
if (!m_data) [[unlikely]]
|
||||||
Panic("Memory allocation failed.");
|
Panic("Memory allocation failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue