Initial Commit
This commit is contained in:
60
source/memory/new.cpp
Normal file
60
source/memory/new.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright (C) 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program 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.
|
||||
//2
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#include <fennec/memory/new.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef FENNEC_MEMORY_DEBUGGER
|
||||
|
||||
#else
|
||||
|
||||
// Allocation functions
|
||||
inline void* operator new (fennec::size_t size) { return malloc(size); }
|
||||
inline void* operator new[](fennec::size_t size) { return malloc(size); }
|
||||
inline void* operator new (fennec::size_t size, const fennec::nothrow_t&) { return malloc(size); }
|
||||
inline void* operator new[](fennec::size_t size, const fennec::nothrow_t&) { return malloc(size); }
|
||||
|
||||
// Aligned allocation functions
|
||||
inline void* operator new (fennec::size_t size, fennec::align_t align) { return aligned_alloc(static_cast<size_t>(align), size); }
|
||||
inline void* operator new[](fennec::size_t size, fennec::align_t align) { return aligned_alloc(static_cast<size_t>(align), size); }
|
||||
inline void* operator new (fennec::size_t size, fennec::align_t align, const fennec::nothrow_t&) { return aligned_alloc(static_cast<size_t>(align), size); }
|
||||
inline void* operator new[](fennec::size_t size, fennec::align_t align, const fennec::nothrow_t&) { return aligned_alloc(static_cast<size_t>(align), size); }
|
||||
|
||||
// Deallocation functions
|
||||
inline void operator delete (void* ptr) noexcept { free(ptr); }
|
||||
inline void operator delete[](void* ptr) noexcept { free(ptr); }
|
||||
|
||||
// Aligned deallocation functions
|
||||
inline void operator delete (void* ptr, fennec::align_t) noexcept { free(ptr); }
|
||||
inline void operator delete[](void* ptr, fennec::align_t) noexcept { free(ptr); }
|
||||
|
||||
// Sized deallocation functions
|
||||
inline void operator delete (void* ptr, fennec::size_t) noexcept { free(ptr); }
|
||||
inline void operator delete[](void* ptr, fennec::size_t) noexcept { free(ptr); }
|
||||
inline void operator delete (void* ptr, fennec::size_t, fennec::align_t) noexcept { free(ptr); }
|
||||
inline void operator delete[](void* ptr, fennec::size_t, fennec::align_t) noexcept { free(ptr); }
|
||||
|
||||
// Non-throwing deallocation functions
|
||||
inline void operator delete (void* ptr, const fennec::nothrow_t&) noexcept { free(ptr); }
|
||||
inline void operator delete[](void* ptr, const fennec::nothrow_t&) noexcept { free(ptr); }
|
||||
inline void operator delete (void* ptr, fennec::align_t, const fennec::nothrow_t&) noexcept { free(ptr); }
|
||||
inline void operator delete[](void* ptr, fennec::align_t, const fennec::nothrow_t&) noexcept { free(ptr); }
|
||||
inline void operator delete (void* ptr, fennec::size_t, const fennec::nothrow_t&) noexcept { free(ptr); }
|
||||
inline void operator delete[](void* ptr, fennec::size_t, const fennec::nothrow_t&) noexcept { free(ptr); }
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user