Commit b76a1b36 by Jonathan Wakely Committed by Jonathan Wakely

Fix error when selecting number of memory pools

	* src/c++17/memory_resource.cc (select_num_pools): Fix off-by-one
	error when block_size is equal to one of the values in the array.

From-SVN: r266092
parent 6c4a1d38
2018-11-13 Jonathan Wakely <jwakely@redhat.com> 2018-11-13 Jonathan Wakely <jwakely@redhat.com>
* src/c++17/memory_resource.cc (select_num_pools): Fix off-by-one
error when block_size is equal to one of the values in the array.
* src/c++17/memory_resource.cc (_Pool::deallocate): Restore * src/c++17/memory_resource.cc (_Pool::deallocate): Restore
attributes to parameters that are only used in assertions. attributes to parameters that are only used in assertions.
......
...@@ -892,7 +892,7 @@ namespace pmr ...@@ -892,7 +892,7 @@ namespace pmr
auto p = std::lower_bound(std::begin(pool_sizes), std::end(pool_sizes), auto p = std::lower_bound(std::begin(pool_sizes), std::end(pool_sizes),
opts.largest_required_pool_block); opts.largest_required_pool_block);
const int n = p - std::begin(pool_sizes); const int n = p - std::begin(pool_sizes);
if (p == std::end(pool_sizes) || *p == opts.largest_required_pool_block) if (p == std::end(pool_sizes))
return n; return n;
return n + 1; return n + 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment