From 37d5981af8bd79506a1a60e5589329c81164c563 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Thu, 25 Nov 2021 11:36:39 +0100 Subject: [PATCH 1/2] Update node_size_helpers to use min_block_size when available. Signed-off-by: Miguel Company --- src/cpp/utils/collections/node_size_helpers.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cpp/utils/collections/node_size_helpers.hpp b/src/cpp/utils/collections/node_size_helpers.hpp index bebab507bb5..181d7ee1fb5 100644 --- a/src/cpp/utils/collections/node_size_helpers.hpp +++ b/src/cpp/utils/collections/node_size_helpers.hpp @@ -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(); +#endif // FOONATHAN_MEMORY_MEMORY_POOL_HAS_MIN_BLOCK_SIZE } private: +#if !defined(FOONATHAN_MEMORY_MEMORY_POOL_HAS_MIN_BLOCK_SIZE) template static CONSTEXPR_FUNC size_t min_size_per_node() { @@ -94,12 +99,9 @@ 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 }; From 6a5afe7f3a43140a29d7fa41bb292777294d835a Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Thu, 25 Nov 2021 12:00:09 +0100 Subject: [PATCH 2/2] Refs 13034. Uncrustify. Signed-off-by: Miguel Company --- src/cpp/utils/collections/node_size_helpers.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cpp/utils/collections/node_size_helpers.hpp b/src/cpp/utils/collections/node_size_helpers.hpp index 181d7ee1fb5..0987fdb9432 100644 --- a/src/cpp/utils/collections/node_size_helpers.hpp +++ b/src/cpp/utils/collections/node_size_helpers.hpp @@ -101,6 +101,7 @@ struct pool_size_helper { return fm::detail::memory_block_stack::implementation_offset; } + #endif // FOONATHAN_MEMORY_MEMORY_POOL_HAS_MIN_BLOCK_SIZE };