2021-05-12 21:50:06 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
|
|
|
* Copyright (C) 2002-2021 PCSX2 Dev Team
|
2009-02-09 21:15:56 +00:00
|
|
|
*
|
2021-05-12 21:50:06 +00:00
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2021-05-12 21:50:06 +00:00
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
2009-02-09 21:15:56 +00:00
|
|
|
*
|
2021-05-12 21:50:06 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-02-09 21:15:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-05-18 13:27:23 +00:00
|
|
|
#include "common/AlignedMalloc.h"
|
|
|
|
|
2021-04-12 09:31:30 +00:00
|
|
|
template <int i>
|
|
|
|
class GSAlignedClass
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2021-11-04 03:07:38 +00:00
|
|
|
protected:
|
|
|
|
GSAlignedClass() = default;
|
|
|
|
~GSAlignedClass() = default;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2021-11-04 03:07:38 +00:00
|
|
|
public:
|
2021-04-12 09:31:30 +00:00
|
|
|
void* operator new(size_t size)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
return _aligned_malloc(size, i);
|
|
|
|
}
|
|
|
|
|
2021-04-12 09:31:30 +00:00
|
|
|
void operator delete(void* p)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
_aligned_free(p);
|
|
|
|
}
|
|
|
|
|
2021-05-03 07:38:08 +00:00
|
|
|
void* operator new(size_t size, void* ptr)
|
|
|
|
{
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2021-11-26 21:50:16 +00:00
|
|
|
void operator delete(void* ptr, void* placement_ptr)
|
|
|
|
{
|
|
|
|
// Just here to satisfy compilers
|
|
|
|
// Person who calls in-place placement new must handle error case
|
|
|
|
}
|
|
|
|
|
2021-04-12 09:31:30 +00:00
|
|
|
void* operator new[](size_t size)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
return _aligned_malloc(size, i);
|
|
|
|
}
|
|
|
|
|
2021-04-12 09:31:30 +00:00
|
|
|
void operator delete[](void* p)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
_aligned_free(p);
|
|
|
|
}
|
|
|
|
};
|