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 <andy.shaw@qt.io>
This commit is contained in:
Thiago Macieira 2021-08-13 18:34:28 -07:00
parent ddea7e6ce9
commit 6feb289189

View File

@ -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<MYSQL_TIME *>(field.outField)->~MYSQL_TIME();
delete[] field.outField;
}
if (d->outBinds) {
delete[] d->outBinds;