aboutsummaryrefslogtreecommitdiff
path: root/src/support/allocators/pool.h
diff options
context:
space:
mode:
authorMartin Leitner-Ankerl <martin.ankerl@gmail.com>2023-11-19 15:57:03 +0100
committerMartin Leitner-Ankerl <martin.ankerl@gmail.com>2023-11-19 18:43:29 +0100
commitce881bf9fcb7c30bb1fafd6ce38844f4f829452a (patch)
tree6d24983b1f30387f655437c40a7624755ea76d2e /src/support/allocators/pool.h
parentd752349029ec7a76f1fd440db2ec2e458d0f3c99 (diff)
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*).
Diffstat (limited to 'src/support/allocators/pool.h')
-rw-r--r--src/support/allocators/pool.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/support/allocators/pool.h b/src/support/allocators/pool.h
index c8e70ebacf..873e260b65 100644
--- a/src/support/allocators/pool.h
+++ b/src/support/allocators/pool.h
@@ -272,7 +272,7 @@ public:
/**
* Forwards all allocations/deallocations to the PoolResource.
*/
-template <class T, std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES>
+template <class T, std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
class PoolAllocator
{
PoolResource<MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES>* m_resource;