@@ -36,9 +36,10 @@ struct Stack {
3636
3737 private:
3838 struct freeobj {
39- freeobj (memory_resource* mr) : resource(mr) {}
39+ freeobj (memory_resource* mr, size_t s ) : resource(mr), size(s ) {}
4040 memory_resource* resource{nullptr };
41- void operator ()(std::byte* ptr) { resource->deallocate (ptr, 0 , alignof (std::max_align_t )); }
41+ size_t size{0 };
42+ void operator ()(std::byte* ptr) { resource->deallocate (ptr, size, alignof (std::max_align_t )); }
4243 };
4344
4445 public:
@@ -99,7 +100,7 @@ struct Stack {
99100 Stack (const allocator_type allocatorArg, Headers&&... headers)
100101 : allocator{allocatorArg},
101102 bufferSize{calculateSize (std::forward<Headers>(headers)...)},
102- buffer{static_cast <std::byte*>(allocator.resource ()->allocate (bufferSize, alignof (std::max_align_t ))), freeobj{allocator.resource ()}}
103+ buffer{static_cast <std::byte*>(allocator.resource ()->allocate (bufferSize, alignof (std::max_align_t ))), freeobj{allocator.resource (), bufferSize }}
103104 {
104105 if constexpr (sizeof ...(headers) > 1 ) {
105106 injectAll (buffer.get (), std::forward<Headers>(headers)...);
@@ -142,7 +143,7 @@ struct Stack {
142143 private:
143144 allocator_type allocator{fair::mq::pmr::new_delete_resource ()};
144145 size_t bufferSize{0 };
145- BufferType buffer{nullptr , freeobj{allocator.resource ()}};
146+ BufferType buffer{nullptr , freeobj{allocator.resource (), 0 }};
146147
147148 // ______________________________________________________________________________________________
148149 template <typename T>
0 commit comments