mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-11-06 03:15:56 +00:00
MemoryManager of base::
This commit is contained in:
parent
8485dcdb03
commit
ead2a1a606
|
@ -237,6 +237,7 @@ project "reLCS"
|
|||
files { addSrcFiles("src/control") }
|
||||
files { addSrcFiles("src/core") }
|
||||
files { addSrcFiles("src/entities") }
|
||||
files { addSrcFiles("src/leeds/base") }
|
||||
files { addSrcFiles("src/math") }
|
||||
files { addSrcFiles("src/modelinfo") }
|
||||
files { addSrcFiles("src/objects") }
|
||||
|
@ -261,6 +262,7 @@ project "reLCS"
|
|||
includedirs { "src/control" }
|
||||
includedirs { "src/core" }
|
||||
includedirs { "src/entities" }
|
||||
includedirs { "src/leeds/base" }
|
||||
includedirs { "src/math" }
|
||||
includedirs { "src/modelinfo" }
|
||||
includedirs { "src/objects" }
|
||||
|
|
|
@ -92,6 +92,7 @@ typedef ptrdiff_t ssize_t;
|
|||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include "memoryManager.h"
|
||||
|
||||
#include <rphanim.h>
|
||||
#include <rpskin.h>
|
||||
|
|
75
src/leeds/base/memoryManager.cpp
Normal file
75
src/leeds/base/memoryManager.cpp
Normal file
|
@ -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);
|
||||
}
|
39
src/leeds/base/memoryManager.h
Normal file
39
src/leeds/base/memoryManager.h
Normal file
|
@ -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);
|
Loading…
Reference in a new issue