Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update node_size_helpers to use min_block_size when available [13034] #2327

Merged
merged 2 commits into from
Nov 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/cpp/utils/collections/node_size_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,20 @@ struct pool_size_helper
static CONSTEXPR_FUNC size_t min_pool_size(
size_t num_nodes)
{
#ifdef FOONATHAN_MEMORY_MEMORY_POOL_HAS_MIN_BLOCK_SIZE
return Pool::min_block_size(node_size, num_nodes ? num_nodes : 1);
#else
return
// Book-keeping area for a block in the memory arena
additional_size_per_pool() +
// At least one node
(num_nodes ? num_nodes : 1) * min_size_per_node<Pool>();
#endif // FOONATHAN_MEMORY_MEMORY_POOL_HAS_MIN_BLOCK_SIZE
}

private:

#if !defined(FOONATHAN_MEMORY_MEMORY_POOL_HAS_MIN_BLOCK_SIZE)
template<typename Pool>
static CONSTEXPR_FUNC size_t min_size_per_node()
{
Expand All @@ -94,13 +99,11 @@ struct pool_size_helper

static CONSTEXPR_FUNC size_t additional_size_per_pool()
{
#ifdef FOONATHAN_MEMORY_MEMORY_POOL_HAS_MIN_BLOCK_SIZE
return fm::detail::memory_block_stack::implementation_offset();
#else
return fm::detail::memory_block_stack::implementation_offset;
#endif // FOONATHAN_MEMORY_MEMORY_POOL_HAS_MIN_BLOCK_SIZE
}

#endif // FOONATHAN_MEMORY_MEMORY_POOL_HAS_MIN_BLOCK_SIZE

};

} // namespace detail
Expand Down