Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Maintenance - Mise à jour mensuelle Lundi 6 Février entre 7h00 et 9h00
Open sidebar
Gauthier Quesnel
irritator
Commits
57c13b66
Commit
57c13b66
authored
Sep 18, 2020
by
Gauthier Quesnel
Browse files
core: remove try_alloc in block_allocator
parent
426d8a70
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/include/irritator/core.hpp
View file @
57c13b66
...
...
@@ -598,30 +598,27 @@ public:
}
}
std
::
pair
<
bool
,
T
*>
try_alloc
()
noexcept
{
if
(
free_head
==
nullptr
&&
max_size
>=
capacity
)
return
{
false
,
nullptr
};
return
{
true
,
alloc
()
};
}
T
*
alloc
()
noexcept
{
++
size
;
block
*
new_block
=
nullptr
;
if
(
free_head
!=
nullptr
)
{
new_block
=
free_head
;
free_head
=
free_head
->
next
;
}
else
{
assert
(
max_size
<
capacity
);
irt_
assert
(
max_size
<
capacity
);
new_block
=
reinterpret_cast
<
block
*>
(
&
blocks
[
max_size
++
]);
}
++
size
;
return
reinterpret_cast
<
T
*>
(
new_block
);
}
bool
can_alloc
()
noexcept
{
return
free_head
!=
nullptr
||
max_size
<
capacity
;
}
void
free
(
T
*
n
)
noexcept
{
assert
(
n
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment