[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - connectivity/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Sep 3 08:08:23 UTC 2018


 connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx |   15 +++-------
 connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx |   15 ++++++----
 connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx          |    2 -
 connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx          |    2 -
 4 files changed, 15 insertions(+), 19 deletions(-)

New commits:
commit 5ef1ea2339c2e527f1ab5e0189e7db4f7b1c9a94
Author:     Tamas Bunth <tamas.bunth at collabora.co.uk>
AuthorDate: Fri Aug 31 11:11:02 2018 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Mon Sep 3 10:08:02 2018 +0200

    mysqlc: Use unique_ptr on C style arrays
    
    Change-Id: Id65487191c29f7af1a171c06345034d1dc5b20ec
    Reviewed-on: https://gerrit.libreoffice.org/59856
    Tested-by: Jenkins
    Reviewed-by: Tamás Bunth <btomi96 at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/59871
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

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;


More information about the Libreoffice-commits mailing list