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 @@ -131,9 +131,16 @@ static ceph::spinlock debug_lock;
131131 new (ptr + datalen) raw_combined (ptr, len, mempool));
132132 }
133133
134- static void operator delete (void *ptr) {
135- raw_combined *raw = (raw_combined *)ptr;
136- aligned_free ((void *)raw->data );
134+ // Custom delete operator that properly handles cleanup of a combined allocation
135+ // where the object is placed after its data buffer. The operator must:
136+ // 1. Save the data pointer before the object is destroyed
137+ // 2. Explicitly call the destructor to clean up the object's members
138+ // 3. Free the entire combined allocation through the data pointer
139+ // Uses std::destroying_delete_t to prevent automatic destructor call after delete
140+ static void operator delete (raw_combined *raw, std::destroying_delete_t ) {
141+ char * dataptr = raw->data ;
142+ raw->~raw_combined ();
143+ aligned_free (dataptr);
137144 }
138145 };
139146
You can’t perform that action at this time.
0 commit comments