summaryrefslogtreecommitdiff
path: root/Runtime/Misc/AllocatorLabels.cpp
blob: c778296d6a118317f4d78ea8eaf2a5da00aaab9e (plain)
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
#include "UnityPrefix.h"
#include "AllocatorLabels.h"
#include "Allocator.h"
#include "Runtime/Profiler/MemoryProfiler.h"

void InitializeMemoryLabels()
{
#define INITIALIZE_LABEL_STRUCT(Name) Name.Initialize(Name##Id);
#define DO_LABEL(Name) INITIALIZE_LABEL_STRUCT(kMem##Name) 
#include "AllocatorLabelNames.h"
#undef DO_LABEL
#undef INITIALIZE_LABEL_STRUCT
}

const char* const MemLabelName[] =
{
#define DO_LABEL(Name) #Name ,
	#include "AllocatorLabelNames.h"
#undef DO_LABEL
};

#define DO_LABEL_STRUCT(Name) EXPORT_COREMODULE Name##Struct Name; 
#define DO_LABEL(Name) DO_LABEL_STRUCT(kMem##Name) 
#include "AllocatorLabelNames.h"
#undef DO_LABEL
#undef DO_LABEL_STRUCT

#if ENABLE_MEM_PROFILER

MemLabelId::MemLabelId( const MemLabelId& other ) : label(other.label), rootReference(NULL)
{	
	rootReference = copy_root_reference(other.rootReference);
}

void MemLabelId::SetRootHeader( ProfilerAllocationHeader* rootHeader )
{
	if (rootReference)
		ReleaseReference();
	rootReference = get_root_reference_from_header(rootHeader);
}

ProfilerAllocationHeader* MemLabelId::GetRootHeader() const
{
	return rootReference ? get_root_header_from_reference(rootReference) : NULL;
}
	
void MemLabelId::ReleaseReference()
{
	release_root_reference(rootReference); 
	rootReference = NULL;
}

const MemLabelId& MemLabelId::operator=( const MemLabelId& other )
{
	label = other.label;
	if (rootReference)
		ReleaseReference();
	rootReference = copy_root_reference(other.rootReference);
	return *this;
}

#endif