From 6feb28918924d80c94b6f435bc3bc981855d59d6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 13 Aug 2021 18:34:28 -0700 Subject: MySQL: pedantism: create and destroy the MYSQL_TIME type This is a no-op. But take the opportunity to make a drive-by update on the loop, which improves it. Change-Id: I4a40ccbd3321467a8429fffd169b08590d28c928 Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/plugins/sqldrivers/mysql') diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index 1f07171ca5..96bba79da1 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -375,6 +375,8 @@ bool QMYSQLResultPrivate::bindInValues() char *field = bind->buffer_length ? new char[bind->buffer_length + 1]{} : nullptr; bind->buffer = f.outField = field; + if (qIsTimeOrDate(fieldInfo->type)) + new (field) MYSQL_TIME; ++i; } @@ -425,9 +427,11 @@ void QMYSQLResult::cleanup() d->meta = 0; } - int i; - for (i = 0; i < d->fields.count(); ++i) - delete[] d->fields[i].outField; + for (const auto &field : qAsConst(d->fields)) { + if (qIsTimeOrDate(field.myField->type)) + reinterpret_cast(field.outField)->~MYSQL_TIME(); + delete[] field.outField; + } if (d->outBinds) { delete[] d->outBinds; -- cgit v1.2.3