@@ -37,9 +37,10 @@ struct Stack {
3737
3838 private:
3939 struct freeobj {
40- freeobj (memory_resource* mr) : resource(mr) {}
40+ freeobj (memory_resource* mr, size_t s ) : resource(mr), size(s ) {}
4141 memory_resource* resource{nullptr };
42- void operator ()(std::byte* ptr) { resource->deallocate (ptr, 0 , alignof (std::max_align_t )); }
42+ size_t size{0 };
43+ void operator ()(std::byte* ptr) { resource->deallocate (ptr, size, alignof (std::max_align_t )); }
4344 };
4445
4546 public:
@@ -100,7 +101,7 @@ struct Stack {
100101 Stack (const allocator_type allocatorArg, Headers&&... headers)
101102 : allocator{allocatorArg},
102103 bufferSize{calculateSize (std::forward<Headers>(headers)...)},
103- buffer{static_cast <std::byte*>(allocator.resource ()->allocate (bufferSize, alignof (std::max_align_t ))), freeobj{allocator.resource ()}}
104+ buffer{static_cast <std::byte*>(allocator.resource ()->allocate (bufferSize, alignof (std::max_align_t ))), freeobj{allocator.resource (), bufferSize }}
104105 {
105106 if constexpr (sizeof ...(headers) > 1 ) {
106107 injectAll (buffer.get (), std::forward<Headers>(headers)...);
@@ -143,7 +144,7 @@ struct Stack {
143144 private:
144145 allocator_type allocator{std::pmr::new_delete_resource ()};
145146 size_t bufferSize{0 };
146- BufferType buffer{nullptr , freeobj{allocator.resource ()}};
147+ BufferType buffer{nullptr , freeobj{allocator.resource (), 0 }};
147148
148149 // ______________________________________________________________________________________________
149150 template <typename T>
0 commit comments