summaryrefslogtreecommitdiffstats
path: root/src/leeds/base/memoryManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/leeds/base/memoryManager.cpp')
-rw-r--r--src/leeds/base/memoryManager.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/leeds/base/memoryManager.cpp b/src/leeds/base/memoryManager.cpp
new file mode 100644
index 00000000..57e7d954
--- /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(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);
+} \ No newline at end of file