Lugdunum
0.1.0
Main Page
+
Namespaces
Namespace List
+
Namespace Members
+
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
+
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
v
Variables
Typedefs
Enumerations
Enumerator
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
:
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
~
+
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
~
+
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
v
w
x
y
Typedefs
Enumerations
+
Related Functions
:
b
c
d
g
l
p
s
w
+
Files
File List
+
File Members
+
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
+
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
+
Macros
d
f
l
n
s
v
w
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
lug
System
Memory
Allocator
Chunk.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cmath>
4
#include <cstddef>
5
#include <
lug/System/Debug.hpp
>
6
#include <
lug/System/Export.hpp
>
7
#include <
lug/System/Memory/Area/IArea.hpp
>
8
#include <
lug/System/Memory/FreeList.hpp
>
9
10
namespace
lug
{
11
namespace
System {
12
namespace
Memory {
13
namespace
Allocator {
14
18
namespace
priv {
19
20
// std::ceil isn't constexpr in clang and msvc
21
constexpr int32_t ceil(
float
num)
22
{
23
return
(static_cast<float>(static_cast<int32_t>(num)) == num)
24
?
static_cast<
int32_t
>
(num)
25
: static_cast<int32_t>(num) + ((num > 0) ? 1 : 0);
26
}
27
28
}
33
template
<
size_t
MaxSize,
size_t
MaxAlignment = MaxSize,
size_t
Offset = 0>
34
class
Chunk
{
35
public
:
36
Chunk
(
lug::System::Memory::Area::IArea
* area);
37
Chunk
(
const
Chunk
&) =
delete
;
38
Chunk
(
Chunk
&&) =
default
;
39
40
Chunk
& operator=(
const
Chunk
&) =
delete
;
41
Chunk
& operator=(
Chunk
&&) =
default
;
42
43
~
Chunk
() =
default
;
44
45
void
* allocate(
size_t
size,
size_t
alignment,
size_t
offset);
46
void
free(
void
* ptr);
47
void
reset();
48
49
size_t
getSize(
void
* ptr)
const
;
50
51
private
:
52
static
constexpr
size_t
ChunkSize = (MaxAlignment <= 1 ? MaxSize : priv::ceil(static_cast<float>(MaxSize) / MaxAlignment) * MaxAlignment);
53
54
lug::System::Memory::Area::IArea
*
const
_area
;
55
FreeList
_freeList{ChunkSize};
56
57
lug::System::Memory::Area::Page
* _currentPage{
nullptr
};
58
lug::System::Memory::Area::Page
* _firstPage{
nullptr
};
59
};
60
61
#include <
lug/System/Memory/Allocator/Chunk.inl
>
62
63
}
// Allocator
64
}
// Memory
65
}
// System
66
}
// lug
IArea.hpp
Export.hpp
Chunk.inl
lug::System::Memory::Area::Page
Definition:
IArea.hpp:12
lug::System::Memory::Allocator::Chunk
Definition:
Chunk.hpp:34
lug::System::Memory::FreeList
Definition:
FreeList.hpp:10
lug
Definition:
Application.hpp:11
FreeList.hpp
lug::System::Memory::Allocator::Chunk::_area
lug::System::Memory::Area::IArea *const _area
Definition:
Chunk.hpp:54
lug::System::Memory::Area::IArea
Definition:
IArea.hpp:20
Debug.hpp
Generated by
1.8.13