Pac-Man Evolution
Loading...
Searching...
No Matches
MemoryManager.h
1/*----------------------------------------------------------------------
2Pac-Man Evolution - Roberto Prieto
3Copyright (C) 2018-2024 MegaStorm Systems
4contact@megastormsystems.com - http://www.megastormsystems.com
5
6This software is provided 'as-is', without any express or implied
7warranty. In no event will the authors be held liable for any damages
8arising from the use of this software.
9
10Permission is granted to anyone to use this software for any purpose,
11including commercial applications, and to alter it and redistribute it
12freely, subject to the following restrictions:
13
141. The origin of this software must not be misrepresented; you must not
15claim that you wrote the original software. If you use this software
16in a product, an acknowledgment in the product documentation would be
17appreciated but is not required.
182. Altered source versions must be plainly marked as such, and must not be
19misrepresented as being the original software.
203. This notice may not be removed or altered from any source distribution.
21
22------------------------------------------------------------------------
23
24Memory Manager
25
26------------------------------------------------------------------------ */
27
28#ifndef MEMORYMANAGERPME_H
29#define MEMORYMANAGERPME_H
30
31// Includes
32#if __has_include(<CRM64Pro/CRM64Pro.h>)
33 #include <CRM64Pro/CRM64Pro.h>
34#else
35 #include <CRM64Pro.h>
36#endif
37using namespace CRM64Pro;
38
39// Enable or disable the memory manager
40#define USE_CMEM
41
42// Use of CMem memory manager
43#ifdef USE_CMEM
44class CMemPME
45{
46public:
47 // These are the only needed operators. It could be extended if needed.
48 void* operator new(size_t, const std::nothrow_t&);
49 void operator delete(void*, const std::nothrow_t&);
50 void operator delete(void*);
51};
52 #define _PME_ALLOC(type,size) (type*)CRM64Pro::CMem::alloc(sizeof(type) * (size), 1)
53 #define _PME_FREE(p) CRM64Pro::CMem::free(p)
54#else
55 class CMemPME {};
56 #define _PME_ALLOC(type, size) new(std::nothrow) type[size]
57 #define _PME_FREE(p) delete[]p
58#endif
59
60#endif