diff --git a/common/AlignedMalloc.cpp b/common/AlignedMalloc.cpp index b7297625ed..adc76fdb8e 100644 --- a/common/AlignedMalloc.cpp +++ b/common/AlignedMalloc.cpp @@ -20,6 +20,7 @@ #include "common/AlignedMalloc.h" #include "common/Assertions.h" +#include void* _aligned_malloc(size_t size, size_t align) { diff --git a/common/AlignedMalloc.h b/common/AlignedMalloc.h index 7caeff4cc9..262f99c7d3 100644 --- a/common/AlignedMalloc.h +++ b/common/AlignedMalloc.h @@ -15,7 +15,17 @@ #pragma once -#include "common/Exceptions.h" +#include "Pcsx2Defs.h" +#include +#include +#include // std::bad_alloc +#include +#include +#include + +#ifdef _MSC_VER +#include +#endif // pxUSE_SECURE_MALLOC - enables bounds checking on scoped malloc allocations. @@ -108,6 +118,20 @@ public: Alloc(size); } + AlignedBuffer(const AlignedBuffer& copy) + { + Alloc(copy.m_size); + if (copy.m_size > 0) + std::memcpy(m_buffer.get(), copy.m_buffer.get(), copy.m_size); + } + + AlignedBuffer(AlignedBuffer&& move) + : m_buffer(std::move(move.m_buffer)) + , m_size(move.m_size) + { + move.m_size = 0; + } + size_t GetSize() const { return m_size; } size_t GetLength() const { return m_size; } @@ -145,6 +169,23 @@ public: Resize(size); } + AlignedBuffer& operator=(const AlignedBuffer& copy) + { + Alloc(copy.m_size); + if (copy.m_size > 0) + std::memcpy(m_buffer.get(), copy.m_buffer.get(), copy.m_size); + + return *this; + } + + AlignedBuffer& operator=(AlignedBuffer&& move) + { + m_buffer = std::move(move.m_buffer); + m_size = move.m_size; + move.m_size = 0; + return *this; + } + T* GetPtr(uint idx = 0) const { #if pxUSE_SECURE_MALLOC