File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -132,9 +132,16 @@ static ceph::spinlock debug_lock;
132132 new (ptr + datalen) raw_combined (ptr, len, mempool));
133133 }
134134
135- static void operator delete (void *ptr) {
136- raw_combined *raw = (raw_combined *)ptr;
137- aligned_free ((void *)raw->data );
135+ // Custom delete operator that properly handles cleanup of a combined allocation
136+ // where the object is placed after its data buffer. The operator must:
137+ // 1. Save the data pointer before the object is destroyed
138+ // 2. Explicitly call the destructor to clean up the object's members
139+ // 3. Free the entire combined allocation through the data pointer
140+ // Uses std::destroying_delete_t to prevent automatic destructor call after delete
141+ static void operator delete (raw_combined *raw, std::destroying_delete_t ) {
142+ char * dataptr = raw->data ;
143+ raw->~raw_combined ();
144+ aligned_free (dataptr);
138145 }
139146 };
140147
You can’t perform that action at this time.
0 commit comments