[Libreoffice-commits] core.git: connectivity/source

Noel Grandin noel.grandin at collabora.co.uk
Mon May 7 09:48:27 UTC 2018


 connectivity/source/drivers/odbc/OPreparedStatement.cxx |   13 ++++++-------
 connectivity/source/inc/odbc/OPreparedStatement.hxx     |    5 ++++-
 2 files changed, 10 insertions(+), 8 deletions(-)

New commits:
commit 4d7867c3ac20083b5fd943f5bca44b102ccbe20e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu May 3 13:52:47 2018 +0200

    loplugin:useuniqueptr in OPreparedStatement
    
    Change-Id: Iea0a8c92bbf7820b5f9e2ab79e7df662e8280b2d
    Reviewed-on: https://gerrit.libreoffice.org/53865
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/connectivity/source/drivers/odbc/OPreparedStatement.cxx b/connectivity/source/drivers/odbc/OPreparedStatement.cxx
index 241a0d8e5f0a..9f0da27ae997 100644
--- a/connectivity/source/drivers/odbc/OPreparedStatement.cxx
+++ b/connectivity/source/drivers/odbc/OPreparedStatement.cxx
@@ -64,12 +64,15 @@ namespace
 OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const OUString& sql)
     :OStatement_BASE2(_pConnection)
     ,numParams(0)
-    ,boundParams(nullptr)
     ,m_bPrepared(false)
 {
     m_sSqlStatement = sql;
 }
 
+OPreparedStatement::~OPreparedStatement()
+{
+}
+
 void SAL_CALL OPreparedStatement::acquire() throw()
 {
     OStatement_BASE2::acquire();
@@ -688,10 +691,7 @@ void OPreparedStatement::initBoundParam ()
 
     if (numParams > 0)
     {
-        // Allocate an array of bound parameter objects
-
-        boundParams = new OBoundParam[numParams];
-
+        boundParams.reset(new OBoundParam[numParams]);
     }
 }
 
@@ -853,8 +853,7 @@ void OPreparedStatement::setStream(
 void OPreparedStatement::FreeParams()
 {
     numParams = 0;
-    delete [] boundParams;
-    boundParams = nullptr;
+    boundParams.reset();
 }
 
 void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)
diff --git a/connectivity/source/inc/odbc/OPreparedStatement.hxx b/connectivity/source/inc/odbc/OPreparedStatement.hxx
index de03832c80e2..c593a859da33 100644
--- a/connectivity/source/inc/odbc/OPreparedStatement.hxx
+++ b/connectivity/source/inc/odbc/OPreparedStatement.hxx
@@ -51,7 +51,7 @@ namespace connectivity
 
             SQLSMALLINT     numParams;      // Number of parameter markers for the prepared statement
 
-            OBoundParam*    boundParams;
+            std::unique_ptr<OBoundParam[]>  boundParams;
                             // Array of bound parameter objects. Each parameter marker will have a
                             // corresponding object to hold bind information, and resulting data.
             css::uno::Reference< css::sdbc::XResultSetMetaData >  m_xMetaData;
@@ -92,6 +92,9 @@ namespace connectivity
             DECLARE_SERVICE_INFO();
             // A ctor, needed to return the object
             OPreparedStatement( OConnection* _pConnection,const OUString& sql);
+            virtual ~OPreparedStatement() override;
+            OPreparedStatement& operator=( OPreparedStatement const & ) = delete; // MSVC2015 workaround
+            OPreparedStatement( OPreparedStatement const & ) = delete; // MSVC2015 workaround
 
             //XInterface
             virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;


More information about the Libreoffice-commits mailing list