Skip to content

Commit 57a7ed4

Browse files
committed
MemoryResources: make sure alignment is always at least 64 bytes
1 parent 600a7b4 commit 57a7ed4

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

DataFormats/MemoryResources/include/MemoryResources/MemoryResources.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ class MessageResource : public FairMQMemoryResource
100100
initialImport = false;
101101
return mMessageData;
102102
} else {
103-
return mUpstream->allocate(bytes, alignment);
103+
return mUpstream->allocate(bytes, alignment < 64 ? 64 : alignment);
104104
}
105105
}
106106
void do_deallocate(void* p, std::size_t bytes, std::size_t alignment) override
107107
{
108-
mUpstream->deallocate(p, bytes, alignment);
108+
mUpstream->deallocate(p, bytes, alignment < 64 ? 64 : alignment);
109109
return;
110110
}
111111
bool do_is_equal(const memory_resource& other) const noexcept override
@@ -208,7 +208,7 @@ class SpectatorAllocator : public boost::container::pmr::polymorphic_allocator<T
208208
{
209209
}
210210

211-
T* allocate(size_t size) { return reinterpret_cast<T*>(this->resource()->allocate(size * sizeof(T), 0)); }
211+
T* allocate(size_t size) { return reinterpret_cast<T*>(this->resource()->allocate(size * sizeof(T), 64)); }
212212
void deallocate(T* ptr, size_t size)
213213
{
214214
this->resource()->deallocate(const_cast<typename std::remove_cv<T>::type*>(ptr), size);
@@ -264,7 +264,7 @@ class OwningMessageSpectatorAllocator
264264
{
265265
}
266266

267-
T* allocate(size_t size) { return reinterpret_cast<T*>(mResource.allocate(size * sizeof(T), 0)); }
267+
T* allocate(size_t size) { return reinterpret_cast<T*>(mResource.allocate(size * sizeof(T), 64)); }
268268
void deallocate(T* ptr, size_t size)
269269
{
270270
mResource.deallocate(const_cast<typename std::remove_cv<T>::type*>(ptr), size);

0 commit comments

Comments
 (0)