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
This commit is contained in:
Jonathan Wakely 2018-11-13 23:44:39 +00:00 committed by Jonathan Wakely
parent 6c4a1d38ba
commit b76a1b3604
2 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,8 @@
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
attributes to parameters that are only used in assertions.

View File

@ -892,7 +892,7 @@ namespace pmr
auto p = std::lower_bound(std::begin(pool_sizes), std::end(pool_sizes),
opts.largest_required_pool_block);
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 + 1;
}