diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-03 13:52:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-07 11:48:06 +0200 |
commit | 4d7867c3ac20083b5fd943f5bca44b102ccbe20e (patch) | |
tree | c084881e11875606a12c99cfa56ce826a231006d /connectivity | |
parent | 210638cc162ce36c8afab3aa64a65afbb5955939 (diff) |
loplugin:useuniqueptr in OPreparedStatement
Change-Id: Iea0a8c92bbf7820b5f9e2ab79e7df662e8280b2d
Reviewed-on: https://gerrit.libreoffice.org/53865
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/odbc/OPreparedStatement.cxx | 13 | ||||
-rw-r--r-- | connectivity/source/inc/odbc/OPreparedStatement.hxx | 5 |
2 files changed, 10 insertions, 8 deletions
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; |