File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -829,9 +829,11 @@ auto make_observable(Args&&... args) {
829829 }
830830 } else {
831831 // Pre-allocate memory
832- constexpr std::size_t block_size = sizeof (control_block_type);
833- constexpr std::size_t object_size = sizeof (object_type);
834- constexpr std::size_t obj_offset = block_size;
832+ constexpr std::size_t block_size = sizeof (control_block_type);
833+ constexpr std::size_t object_size = sizeof (object_type);
834+ constexpr std::size_t object_align = alignof (object_type);
835+ constexpr std::size_t align_padding = object_align - 1 - ((block_size - 1 ) % object_align);
836+ constexpr std::size_t obj_offset = block_size + align_padding;
835837
836838 std::byte* buffer = reinterpret_cast <std::byte*>(operator new (obj_offset + object_size));
837839
You can’t perform that action at this time.
0 commit comments