Lugdunum
0.1.0
include
lug
System
Memory
Area
Heap.inl
Go to the documentation of this file.
1
template
<
size_t
PageSize,
size_t
PageCount>
2
lug::System::Memory::Area::Heap<PageSize, PageCount>::Heap
() {
3
_data = std::malloc(PageSize * PageCount);
4
5
char
*
const
tmpPtr =
static_cast<
char
*
>
(_data);
6
for
(
size_t
i = 0; i < PageCount; ++i) {
7
_pages[i] = {
8
tmpPtr + PageSize * i,
9
tmpPtr + PageSize * (i + 1) - 1,
10
i == 0 ?
nullptr
: &_pages[i - 1],
11
nullptr
12
};
13
}
14
}
15
16
template
<
size_t
PageSize,
size_t
PageCount>
17
lug::System::Memory::Area::Heap<PageSize, PageCount>::~Heap
() {
18
std::free(_data);
19
_data =
nullptr
;
20
}
21
22
template
<
size_t
PageSize,
size_t
PageCount>
23
inline
Page
*
lug::System::Memory::Area::Heap<PageSize, PageCount>::requestNextPage
() {
24
if
(_current >= PageCount) {
25
return
nullptr
;
26
}
27
28
_current += 1;
29
return
&_pages[_current - 1];
30
}
lug::System::Memory::Area::Heap::~Heap
~Heap()
Definition:
Heap.inl:17
lug::System::Memory::Area::Page
Definition:
IArea.hpp:12
lug::System::Memory::Area::Heap::requestNextPage
Page * requestNextPage() override
Definition:
Heap.inl:23
lug::System::Memory::Area::Heap::Heap
Heap()
Definition:
Heap.inl:2
Generated by
1.8.13