OpenBarnyard
 
Loading...
Searching...
No Matches
AMemory.cpp
Go to the documentation of this file.
1#include "pch.h"
2#include "AMemory.h"
3
4//-----------------------------------------------------------------------------
5// Enables memory debugging.
6// Note: Should be the last include!
7//-----------------------------------------------------------------------------
9
11
13{
14 TASSERT( a_ePool >= POOL_None && a_ePool < POOL_NUMOF );
15
16 auto& rPool = s_aPools[ a_ePool ];
17 TMemory::MemBlock* pAllocOnHeap = ( rPool.GetHeapIndex() == a_ePool ) ?
18 TNULL :
19 s_aMemBlocks[ rPool.GetHeapIndex() ];
20
21 s_aMemBlocks[ a_ePool ] = g_pMemory->CreateMemBlock(
22 rPool.GetSize(),
23 rPool.GetName(),
24 pAllocOnHeap,
25 rPool.GetUnk2()
26 );
27
28 s_AllocatorList.aAllocators[ a_ePool ].SetMemBlock( s_aMemBlocks[ a_ePool ] );
29}
30
31T2Allocator* AMemory::GetAllocator( POOL a_ePool )
32{
33 TASSERT( a_ePool >= POOL_None && a_ePool < POOL_NUMOF );
34
35 return &s_AllocatorList.aAllocators[ a_ePool ];
36}
37
39{
40 TASSERT( a_ePool >= POOL_None && a_ePool < POOL_NUMOF );
41
42 return s_aMemBlocks[ a_ePool ];
43}
#define TASSERT(X,...)
Definition Defines.h:138
#define TOSHI_NAMESPACE_USING
Definition Defines.h:46
#define TNULL
Definition Typedefs.h:23
TMemory * g_pMemory
Definition TMemory.cpp:131
Represents a contiguous block of memory that can be allocated from.
Definition TMemory.h:101
@ POOL_None
Definition AMemory.h:33
@ POOL_NUMOF
Definition AMemory.h:41
static Toshi::T2Allocator * GetAllocator(POOL a_ePool)
Definition AMemory.cpp:31
static constexpr AMemoryPool s_aPools[POOL_NUMOF]
Definition AMemory.h:53
static Toshi::TMemory::MemBlock * s_aMemBlocks[POOL_NUMOF]
Definition AMemory.h:50
static Toshi::TMemory::MemBlock * GetMemBlock(POOL a_ePool)
Definition AMemory.cpp:38
uint32_t POOL
Definition AMemory.h:30
static void CreatePool(POOL a_ePool)
Definition AMemory.cpp:12
static AllocatorList s_AllocatorList
Definition AMemory.h:51