slab: add option to free empty blocks

explictly by a method

Issue #4014
This commit is contained in:
Alexander Boettcher
2021-02-09 23:06:16 +01:00
committed by Norman Feske
parent 19d0142e10
commit 1e84b46c3f
4 changed files with 23 additions and 1 deletions

View File

@ -416,6 +416,17 @@ void Slab::_free(void *addr)
}
void Slab::free_empty_blocks()
{
for (size_t blocks = _num_blocks; blocks > 0; blocks--) {
if (_curr_sb != _initial_sb && _curr_sb->avail() == _entries_per_block)
_free_curr_sb();
else
_curr_sb = _curr_sb->next;
}
}
void *Slab::any_used_elem()
{
if (_total_avail == _num_blocks*_entries_per_block)