Skip to content

Commit

Permalink
Throw an exception if max_node_size is too big for block_size of
Browse files Browse the repository at this point in the history
`memory_pool_collection`

Fixes #145.
  • Loading branch information
foonathan committed Jan 11, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 6eaa58e commit 9d3bda1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/foonathan/memory/memory_pool_collection.hpp
Original file line number Diff line number Diff line change
@@ -75,15 +75,15 @@ namespace foonathan
/// the size of the initial memory block and other constructor arguments for the \concept{concept_blockallocator,BlockAllocator}.
/// The \c BucketDistribution controls how many free lists are created,
/// but unlike in \ref memory_pool all free lists are initially empty and the first memory block queued.
/// \requires \c max_node_size must be a valid \concept{concept_node,node} size
/// and \c block_size must be non-zero.
/// \requires \c block_size must be non-zero and \c max_node_size must be a valid \concept{concept_node,node} size and smaller than \c block_size divided by the number of pools.
template <typename... Args>
memory_pool_collection(std::size_t max_node_size, std::size_t block_size,
Args&&... args)
: arena_(block_size, detail::forward<Args>(args)...),
stack_(allocate_block()),
pools_(stack_, block_end(), max_node_size)
{
detail::check_allocation_size<bad_node_size>(max_node_size, def_capacity(), info());
}

/// \effects Destroys the \ref memory_pool_collection by returning all memory blocks,

0 comments on commit 9d3bda1

Please sign in to comment.