blob: 57e7d9544c193dc2b7d71d8ea4ed0f9f2e70c017 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include "common.h"
#include "memoryManager.h"
namespace base
{
cMemoryManager::cMemoryManager()
{
}
void* cMemoryManager::Allocate(uint32 size)
{
void* buf = malloc(size);
memset(buf, 0, size);
return buf;
}
void* cMemoryManager::AllocateAligned(uint32 size)
{
void* buf = malloc(size);
memset(buf, 0, size);
return buf;
}
void* cMemoryManager::Realloc(void* buf, uint32 newSize, bool unk)
{
return realloc(buf, newSize);
}
void cMemoryManager::Free(void* buf)
{
if (buf)
free(buf);
}
bool cMemoryManager::IsFree(void* buf)
{
return buf == nil;
}
cMainMemoryManager* cMainMemoryManager::m_pInstance = nil;
cMainMemoryManager::cMainMemoryManager()
{
assert(m_pInstance == nil);
m_pInstance = this;
Init(nil, 0);
}
void cMainMemoryManager::Init(void*, uint32)
{
}
};
void* operator new(size_t size)
{
return base::cMainMemoryManager::Instance()->Allocate(size);
}
void* operator new[](size_t size)
{
return base::cMainMemoryManager::Instance()->Allocate(size);
}
void operator delete(void* buf) noexcept
{
base::cMainMemoryManager::Instance()->Free(buf);
}
void operator delete[](void* buf) noexcept
{
base::cMainMemoryManager::Instance()->Free(buf);
}
|