diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-05 08:57:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-05 11:30:12 +0200 |
commit | b0e05f9ade9e93c569c6a62c59ac1819e615f27b (patch) | |
tree | 61cbf40294b73e5dbc92213c23f1d89dd8998092 /connectivity | |
parent | 1a637473b5aa6a43acb4d1f820044fba962cc6a4 (diff) |
loplugin:useuniqueptr in basic..cppcanvas
Change-Id: Ib40241eb794607154ae52f8aa68fbf5ea5e944af
Reviewed-on: https://gerrit.libreoffice.org/39551
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
4 files changed, 12 insertions, 16 deletions
diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx index 44da0bb72aac..796f34a786c2 100644 --- a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx @@ -68,9 +68,8 @@ ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection throw RuntimeException(); osl_atomic_increment( &m_refCount ); - m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value + m_pRowStatusArray.reset( new SQLUSMALLINT[1] ); // the default value osl_atomic_decrement( &m_refCount ); - // allocBuffer(); } @@ -82,7 +81,6 @@ ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet() osl_atomic_increment( &m_refCount ); dispose(); } - delete [] m_pRowStatusArray; } void ODatabaseMetaDataResultSet::disposing() diff --git a/connectivity/source/drivers/odbc/OResultSet.cxx b/connectivity/source/drivers/odbc/OResultSet.cxx index 475d2fe286b4..203402eb5b35 100644 --- a/connectivity/source/drivers/odbc/OResultSet.cxx +++ b/connectivity/source/drivers/odbc/OResultSet.cxx @@ -104,8 +104,8 @@ OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) : osl_atomic_increment( &m_refCount ); try { - m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value - setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR, m_pRowStatusArray); + m_pRowStatusArray.reset( new SQLUSMALLINT[1] ); // the default value + setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR, m_pRowStatusArray.get()); } catch(const Exception&) { // we don't want our result destroy here @@ -117,7 +117,7 @@ OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) : SQLUINTEGER nValueLen = m_pStatement->getCursorProperties(nCurType,false); if( (nValueLen & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS || (nValueLen & SQL_CA2_CRC_EXACT) != SQL_CA2_CRC_EXACT) - m_pSkipDeletedSet = new OSkipDeletedSet(this); + m_pSkipDeletedSet.reset( new OSkipDeletedSet(this) ); } catch(const Exception&) { // we don't want our result destroy here @@ -164,8 +164,6 @@ OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) : OResultSet::~OResultSet() { - delete [] m_pRowStatusArray; - delete m_pSkipDeletedSet; } void OResultSet::construct() @@ -1389,10 +1387,8 @@ void OResultSet::setFetchSize(sal_Int32 _par0) if ( _par0 > 0 ) { setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_ROW_ARRAY_SIZE, _par0); - delete [] m_pRowStatusArray; - - m_pRowStatusArray = new SQLUSMALLINT[_par0]; - setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR, m_pRowStatusArray); + m_pRowStatusArray.reset( new SQLUSMALLINT[_par0] ); + setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR, m_pRowStatusArray.get()); } } diff --git a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx index 56e3b5062bbf..c242c2eee85c 100644 --- a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx +++ b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx @@ -39,6 +39,7 @@ #include "odbc/ODatabaseMetaData.hxx" #include "odbc/odbcbasedllapi.hxx" #include <connectivity/StdTypeDefs.hxx> +#include <memory> namespace connectivity { @@ -72,7 +73,7 @@ namespace connectivity css::uno::WeakReferenceHelper m_aStatement; css::uno::Reference< css::sdbc::XResultSetMetaData> m_xMetaData; - SQLUSMALLINT* m_pRowStatusArray; + std::unique_ptr<SQLUSMALLINT[]> m_pRowStatusArray; rtl::Reference<OConnection> m_pConnection; rtl_TextEncoding m_nTextEncoding; sal_Int32 m_nRowPos; diff --git a/connectivity/source/inc/odbc/OResultSet.hxx b/connectivity/source/inc/odbc/OResultSet.hxx index b09310519698..d1f75371cfe0 100644 --- a/connectivity/source/inc/odbc/OResultSet.hxx +++ b/connectivity/source/inc/odbc/OResultSet.hxx @@ -40,6 +40,7 @@ #include <connectivity/CommonTools.hxx> #include <connectivity/FValue.hxx> #include "TSkipDeletedSet.hxx" +#include <memory> namespace connectivity { @@ -130,14 +131,14 @@ namespace connectivity // Else, we read and cache all columns whose number is <= a requested column. // m_aRow[colNumber].getBound() says if it contains an up-to-date value or not. TDataRow m_aRow; - bool m_bFetchDataInOrder; + bool m_bFetchDataInOrder; SQLHANDLE m_aStatementHandle; SQLHANDLE m_aConnectionHandle; OStatement_Base* m_pStatement; - OSkipDeletedSet* m_pSkipDeletedSet; + std::unique_ptr<OSkipDeletedSet> m_pSkipDeletedSet; css::uno::Reference< css::uno::XInterface> m_xStatement; css::uno::Reference< css::sdbc::XResultSetMetaData> m_xMetaData; - SQLUSMALLINT* m_pRowStatusArray; + std::unique_ptr<SQLUSMALLINT[]> m_pRowStatusArray; rtl_TextEncoding m_nTextEncoding; sal_Int32 m_nRowPos; mutable sal_uInt32 m_nUseBookmarks; |