diff options
author | Sergeanur <s.anureev@yandex.ua> | 2021-01-08 15:47:41 +0100 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2021-01-08 15:47:41 +0100 |
commit | ead2a1a60604f00182a869a5f0c8069db749a83d (patch) | |
tree | fb0a00a0969db2080be713acfccae0e88eb912ce /src/leeds | |
parent | Update readme and workflows (diff) | |
download | re3-ead2a1a60604f00182a869a5f0c8069db749a83d.tar re3-ead2a1a60604f00182a869a5f0c8069db749a83d.tar.gz re3-ead2a1a60604f00182a869a5f0c8069db749a83d.tar.bz2 re3-ead2a1a60604f00182a869a5f0c8069db749a83d.tar.lz re3-ead2a1a60604f00182a869a5f0c8069db749a83d.tar.xz re3-ead2a1a60604f00182a869a5f0c8069db749a83d.tar.zst re3-ead2a1a60604f00182a869a5f0c8069db749a83d.zip |
Diffstat (limited to 'src/leeds')
-rw-r--r-- | src/leeds/base/memoryManager.cpp | 75 | ||||
-rw-r--r-- | src/leeds/base/memoryManager.h | 39 |
2 files changed, 114 insertions, 0 deletions
diff --git a/src/leeds/base/memoryManager.cpp b/src/leeds/base/memoryManager.cpp new file mode 100644 index 00000000..7f6145bd --- /dev/null +++ b/src/leeds/base/memoryManager.cpp @@ -0,0 +1,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(uint32 size) +{ + return base::cMainMemoryManager::Instance()->Allocate(size); +} + +void* operator new[](uint32 size) +{ + return base::cMainMemoryManager::Instance()->Allocate(size); +} + +void operator delete(void* buf) +{ + base::cMainMemoryManager::Instance()->Free(buf); +} + +void operator delete[](void* buf) +{ + base::cMainMemoryManager::Instance()->Free(buf); +}
\ No newline at end of file diff --git a/src/leeds/base/memoryManager.h b/src/leeds/base/memoryManager.h new file mode 100644 index 00000000..97ee4a43 --- /dev/null +++ b/src/leeds/base/memoryManager.h @@ -0,0 +1,39 @@ +#pragma once + +namespace base +{ + class cMemoryManager + { + public: + cMemoryManager(); + void* Allocate(uint32 size); + void* AllocateAligned(uint32 size); + void* Realloc(void* buf, uint32 newSize, bool unk); + void Free(void* buf); + bool IsFree(void* buf); + }; + + class cMainMemoryManager : public cMemoryManager + { + static cMainMemoryManager* m_pInstance; + static void Init(void*, uint32); + + public: + cMainMemoryManager(); + static cMainMemoryManager *Instance() + { + static cMainMemoryManager instance; + return &instance; + } + }; + + class cMemoryBlock + { + // TODO + }; +} + +void* operator new(uint32 size); +void* operator new[](uint32 size); +void operator delete(void* buf); +void operator delete[](void* buf);
\ No newline at end of file |