]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/python/object/make_instance.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / python / object / make_instance.hpp
index 31ec08f7c352d5eca77c92fa4bd5ceae76c69c71..713fdc5ecde66d350645c40f750f3cff6176876c 100644 (file)
@@ -43,11 +43,14 @@ struct make_instance_impl
             
             // construct the new C++ object and install the pointer
             // in the Python object.
-            Derived::construct(&instance->storage, (PyObject*)instance, x)->install(raw_result);
+            Holder *holder =Derived::construct(instance->storage.bytes, (PyObject*)instance, x);
+            holder->install(raw_result);
               
             // Note the position of the internally-stored Holder,
             // for the sake of destruction
-            Py_SIZE(instance) = offsetof(instance_t, storage);
+            const size_t offset = reinterpret_cast<size_t>(holder) -
+              reinterpret_cast<size_t>(instance->storage.bytes) + offsetof(instance_t, storage);
+            Py_SET_SIZE(instance, offset);
 
             // Release ownership of the python object
             protect.cancel();
@@ -69,7 +72,10 @@ struct make_instance
     
     static inline Holder* construct(void* storage, PyObject* instance, reference_wrapper<T const> x)
     {
-        return new (storage) Holder(instance, x);
+        size_t allocated = objects::additional_instance_size<Holder>::value;
+        void* aligned_storage = ::boost::alignment::align(boost::python::detail::alignment_of<Holder>::value,
+                                                          sizeof(Holder), storage, allocated);
+        return new (aligned_storage) Holder(instance, x);
     }
 };