mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 18:52:29 +02:00
pool: make sure PoolAllocator uses the correct alignment
This changes the PoolAllocator to default the alignment to the given type. This makes the code simpler, and most importantly fixes a bug on ARM 32bit that caused OOM: The class CTxOut has a member CAmount which is an int64_t and on ARM 32bit int64_t are 8 byte aligned which is larger than the pointer alignment of 4 bytes. So for CCoinsMap to be able to use the pool, we need to use the alignment of the member instead of just alignof(void*).
This commit is contained in:
@@ -37,8 +37,7 @@ static void PoolAllocator_StdUnorderedMapWithPoolResource(benchmark::Bench& benc
|
||||
std::hash<uint64_t>,
|
||||
std::equal_to<uint64_t>,
|
||||
PoolAllocator<std::pair<const uint64_t, uint64_t>,
|
||||
sizeof(std::pair<const uint64_t, uint64_t>) + 4 * sizeof(void*),
|
||||
alignof(void*)>>;
|
||||
sizeof(std::pair<const uint64_t, uint64_t>) + 4 * sizeof(void*)>>;
|
||||
|
||||
// make sure the resource supports large enough pools to hold the node. We do this by adding the size of a few pointers to it.
|
||||
auto pool_resource = Map::allocator_type::ResourceType();
|
||||
|
||||
Reference in New Issue
Block a user