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