diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-13 14:20:55 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-15 08:38:59 +0200 |
commit | 48baa68e3ac12bbaf0d5b7912a0197accf341b25 (patch) | |
tree | 688a04624b9789204aa4008a55f51a62a3e14de1 /mysqlc/source | |
parent | 2088dac08b729805e981465526be3aad090462f0 (diff) |
loplugin:useuniqueptr in OPreparedResultSet
Change-Id: Ieb536bb2ab7cef378b7279e086b26762f4291c56
Reviewed-on: https://gerrit.libreoffice.org/59014
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'mysqlc/source')
-rw-r--r-- | mysqlc/source/mysqlc_prepared_resultset.cxx | 17 | ||||
-rw-r--r-- | mysqlc/source/mysqlc_prepared_resultset.hxx | 6 |
2 files changed, 10 insertions, 13 deletions
diff --git a/mysqlc/source/mysqlc_prepared_resultset.cxx b/mysqlc/source/mysqlc_prepared_resultset.cxx index d66259d0a9db..1d5b9ad359bf 100644 --- a/mysqlc/source/mysqlc_prepared_resultset.cxx +++ b/mysqlc/source/mysqlc_prepared_resultset.cxx @@ -84,7 +84,7 @@ OPreparedResultSet::OPreparedResultSet(OConnection& rConn, OPreparedStatement* p { m_nFieldCount = mysql_stmt_field_count(pStmt); m_pResult = mysql_stmt_result_metadata(m_pStmt); - m_aFields = mysql_fetch_fields(m_pResult); + m_aFields.reset(mysql_fetch_fields(m_pResult)); } OPreparedResultSet::~OPreparedResultSet() {} @@ -505,11 +505,8 @@ void SAL_CALL OPreparedResultSet::close() MutexGuard aGuard(m_aMutex); checkDisposed(OPreparedResultSet_BASE::rBHelper.bDisposed); - if (m_aData) - { - delete[] m_aData; - delete[] m_aMetaData; - } + m_aData.reset(); + m_aMetaData.reset(); if (m_pResult) mysql_free_result(m_pResult); @@ -636,9 +633,9 @@ sal_Bool SAL_CALL OPreparedResultSet::next() if (m_aData == nullptr) { bFirstRun = true; - m_aData = new MYSQL_BIND[m_nFieldCount]; - memset(m_aData, 0, m_nFieldCount * sizeof(MYSQL_BIND)); - m_aMetaData = new BindMetaData[m_nFieldCount]; + m_aData.reset(new MYSQL_BIND[m_nFieldCount]); + memset(m_aData.get(), 0, m_nFieldCount * sizeof(MYSQL_BIND)); + m_aMetaData.reset(new BindMetaData[m_nFieldCount]); } for (sal_Int32 i = 0; i < m_nFieldCount; ++i) { @@ -657,7 +654,7 @@ sal_Bool SAL_CALL OPreparedResultSet::next() mysqlc_sdbc_driver::allocateSqlVar(&m_aData[i].buffer, m_aData[i].buffer_type, m_aFields[i].length); } - mysql_stmt_bind_result(m_pStmt, m_aData); + mysql_stmt_bind_result(m_pStmt, m_aData.get()); if (bFirstRun) mysql_stmt_store_result(m_pStmt); int failure = mysql_stmt_fetch(m_pStmt); diff --git a/mysqlc/source/mysqlc_prepared_resultset.hxx b/mysqlc/source/mysqlc_prepared_resultset.hxx index db3e1034cb76..53a1b0af10a9 100644 --- a/mysqlc/source/mysqlc_prepared_resultset.hxx +++ b/mysqlc/source/mysqlc_prepared_resultset.hxx @@ -70,9 +70,9 @@ class OPreparedResultSet final : public OBase_Mutex, // Use c style arrays, because we have to work with pointers // on these. - MYSQL_BIND* m_aData = nullptr; - MYSQL_FIELD* m_aFields = nullptr; - BindMetaData* m_aMetaData = nullptr; + std::unique_ptr<MYSQL_BIND[]> m_aData; + std::unique_ptr<MYSQL_FIELD[]> m_aFields; + std::unique_ptr<BindMetaData[]> m_aMetaData; bool m_bWasNull = false; |