Skip to content

Commit 44b5602

Browse files
committed
QMetaType: use sized delete to deallocate a value
When destroying a value created by QMetaType::create(), pass the size to operator delete. This allows allocators to potentially optimize the deallocation. The size passed is always the one used during allocation, iface->size. As a drive-by, make the operator() function const. Change-Id: I3224af525671d98327d21033d059f52620fbb837 Reviewed-by: Thiago Macieira <[email protected]>
1 parent bee20b2 commit 44b5602

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/corelib/kernel/qmetatype.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ namespace {
7474
struct QMetaTypeDeleter
7575
{
7676
const QtPrivate::QMetaTypeInterface *iface;
77-
void operator()(void *data)
77+
void operator()(void *data) const
7878
{
7979
if (iface->alignment > __STDCPP_DEFAULT_NEW_ALIGNMENT__) {
80-
operator delete(data, std::align_val_t(iface->alignment));
80+
operator delete(data, iface->size, std::align_val_t(iface->alignment));
8181
} else {
82-
operator delete(data);
82+
operator delete(data, iface->size);
8383
}
8484
}
8585
};

0 commit comments

Comments
 (0)