diff options
4 files changed, 15 insertions, 19 deletions
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx index 7b84661b8e21..695f6973512e 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx @@ -84,8 +84,6 @@ OPreparedResultSet::OPreparedResultSet(OConnection& rConn, OPreparedStatement* p m_aFields = mysql_fetch_fields(m_pResult); } -OPreparedResultSet::~OPreparedResultSet() {} - void OPreparedResultSet::disposing() { OPropertySetHelper::disposing(); @@ -502,11 +500,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); @@ -633,9 +628,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) { diff --git a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx index 5cbb37f5bd6d..93690d194fdf 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx @@ -62,17 +62,20 @@ class OPreparedResultSet final : public OBase_Mutex, OConnection& m_rConnection; css::uno::WeakReferenceHelper m_aStatement; css::uno::Reference<css::sdbc::XResultSetMetaData> m_xMetaData; - MYSQL_RES* m_pResult; - MYSQL_STMT* m_pStmt; + + // non-owning pointers + MYSQL_RES* m_pResult = nullptr; + MYSQL_STMT* m_pStmt = nullptr; + MYSQL_FIELD* m_aFields = nullptr; + rtl_TextEncoding m_encoding; sal_Int32 m_nCurrentField = 0; sal_Int32 m_nFieldCount; // 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<BindMetaData[]> m_aMetaData; bool m_bWasNull = false; @@ -90,7 +93,7 @@ class OPreparedResultSet final : public OBase_Mutex, void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const SAL_OVERRIDE; // you can't delete objects of this type - virtual ~OPreparedResultSet() override; + virtual ~OPreparedResultSet() override = default; public: virtual rtl::OUString SAL_CALL getImplementationName() SAL_OVERRIDE; diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx index c52b587fba55..aa2f821fb868 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx @@ -108,8 +108,6 @@ OResultSet::OResultSet(OConnection& rConn, OCommonStatement* pStmt, MYSQL_RES* p fieldCount = mysql_num_fields(pResult); } -OResultSet::~OResultSet() {} - void OResultSet::disposing() { OPropertySetHelper::disposing(); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx index c4a203cda91e..9bfd8ecc1aef 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx @@ -87,7 +87,7 @@ class OResultSet final : public OBase_Mutex, void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const SAL_OVERRIDE; // you can't delete objects of this type - virtual ~OResultSet() override; + virtual ~OResultSet() override = default; public: virtual rtl::OUString SAL_CALL getImplementationName() SAL_OVERRIDE; |