summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-12-19 10:52:31 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-12-19 12:31:19 +0100
commit415c2e54e758172ff4f614239128b2aa0ddad49e (patch)
tree7810044327ca9f733525b16b801df81f1a3df1f3 /connectivity
parentef8de8d202deb92a57b52f4e48a4de77cf6d8b34 (diff)
use unique_ptr in connectivity
Change-Id: I333a3bc21d4afade6d29f096390b5edbd4e78bf9 Reviewed-on: https://gerrit.libreoffice.org/65403 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/dbase/DIndex.cxx5
-rw-r--r--connectivity/source/drivers/dbase/DResultSet.cxx3
-rw-r--r--connectivity/source/drivers/jdbc/DatabaseMetaData.cxx9
-rw-r--r--connectivity/source/drivers/jdbc/JConnection.cxx5
-rw-r--r--connectivity/source/drivers/jdbc/tools.cxx4
-rw-r--r--connectivity/source/inc/dbase/DIndex.hxx2
-rw-r--r--connectivity/source/inc/java/tools.hxx2
7 files changed, 14 insertions, 16 deletions
diff --git a/connectivity/source/drivers/dbase/DIndex.cxx b/connectivity/source/drivers/dbase/DIndex.cxx
index 70e9eed51335..b48359afdde1 100644
--- a/connectivity/source/drivers/dbase/DIndex.cxx
+++ b/connectivity/source/drivers/dbase/DIndex.cxx
@@ -37,6 +37,7 @@
#include <dbase/DResultSet.hxx>
#include <strings.hrc>
#include <unotools/sharedunocomponent.hxx>
+#include <o3tl/make_unique.hxx>
using namespace ::comphelper;
@@ -159,10 +160,10 @@ void ODbaseIndex::openIndexFile()
}
}
-OIndexIterator* ODbaseIndex::createIterator()
+std::unique_ptr<OIndexIterator> ODbaseIndex::createIterator()
{
openIndexFile();
- return new OIndexIterator(this);
+ return o3tl::make_unique<OIndexIterator>(this);
}
bool ODbaseIndex::ConvertToKey(ONDXKey* rKey, sal_uInt32 nRec, const ORowSetValue& rValue)
diff --git a/connectivity/source/drivers/dbase/DResultSet.cxx b/connectivity/source/drivers/dbase/DResultSet.cxx
index 7e41b2402af5..5d5b7b3122e5 100644
--- a/connectivity/source/drivers/dbase/DResultSet.cxx
+++ b/connectivity/source/drivers/dbase/DResultSet.cxx
@@ -163,7 +163,7 @@ bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xInde
dbase::ODbaseIndex* pIndex = reinterpret_cast< dbase::ODbaseIndex* >( xTunnel->getSomething(dbase::ODbaseIndex::getUnoTunnelImplementationId()) );
if(pIndex)
{
- dbase::OIndexIterator* pIter = pIndex->createIterator();
+ std::unique_ptr<dbase::OIndexIterator> pIter = pIndex->createIterator();
if (pIter)
{
@@ -174,7 +174,6 @@ bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xInde
nRec = pIter->Next();
}
m_pFileSet->setFrozen();
- delete pIter;
return true;
}
}
diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
index ee991d4c1338..62d41a42d7e0 100644
--- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
@@ -196,14 +196,13 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables(
{
if ( t.pEnv->IsInstanceOf( jThrow,java_sql_SQLException_BASE::st_getMyClass() ) )
{
- java_sql_SQLException_BASE* pException = new java_sql_SQLException_BASE( t.pEnv, jThrow );
- SQLException e( pException->getMessage(),
+ java_sql_SQLException_BASE aException( t.pEnv, jThrow );
+ SQLException e( aException.getMessage(),
*this,
- pException->getSQLState(),
- pException->getErrorCode(),
+ aException.getSQLState(),
+ aException.getErrorCode(),
Any()
);
- delete pException;
throw e;
}
}
diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx
index 3e365c74478f..8d0dfe141b54 100644
--- a/connectivity/source/drivers/jdbc/JConnection.cxx
+++ b/connectivity/source/drivers/jdbc/JConnection.cxx
@@ -770,7 +770,7 @@ bool java_sql_Connection::construct(const OUString& url,
jvalue args[2];
// convert Parameter
args[0].l = convertwchar_tToJavaString(t.pEnv,url);
- java_util_Properties* pProps = createStringPropertyArray(info);
+ std::unique_ptr<java_util_Properties> pProps = createStringPropertyArray(info);
args[1].l = pProps->getJavaObject();
LocalRef< jobject > ensureDelete( t.env(), args[0].l );
@@ -792,8 +792,7 @@ bool java_sql_Connection::construct(const OUString& url,
{
ContextClassLoaderScope ccl( t.env(), getDriverClassLoader(), getLogger(), *this );
out = t.pEnv->CallObjectMethod( m_pDriverobject, mID, args[0].l,args[1].l );
- delete pProps;
- pProps = nullptr;
+ pProps.reset();
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
}
diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx
index 58d7744333af..29b68991b5f5 100644
--- a/connectivity/source/drivers/jdbc/tools.cxx
+++ b/connectivity/source/drivers/jdbc/tools.cxx
@@ -103,9 +103,9 @@ jstring connectivity::convertwchar_tToJavaString(JNIEnv *pEnv,const OUString& _r
}
-java_util_Properties* connectivity::createStringPropertyArray(const Sequence< PropertyValue >& info )
+std::unique_ptr<java_util_Properties> connectivity::createStringPropertyArray(const Sequence< PropertyValue >& info )
{
- java_util_Properties* pProps = new java_util_Properties();
+ std::unique_ptr<java_util_Properties> pProps(new java_util_Properties());
const PropertyValue* pBegin = info.getConstArray();
const PropertyValue* pEnd = pBegin + info.getLength();
diff --git a/connectivity/source/inc/dbase/DIndex.hxx b/connectivity/source/inc/dbase/DIndex.hxx
index de079cbff907..e1452967e130 100644
--- a/connectivity/source/inc/dbase/DIndex.hxx
+++ b/connectivity/source/inc/dbase/DIndex.hxx
@@ -101,7 +101,7 @@ namespace connectivity
const ODbaseTable* getTable() const { return m_pTable; }
const NDXHeader& getHeader() const { return m_aHeader; }
- OIndexIterator* createIterator();
+ std::unique_ptr<OIndexIterator> createIterator();
void SetRootPos(sal_uInt32 nPos) {m_nRootPage = nPos;}
void SetPageCount(sal_uInt32 nCount) {m_nPageCount = nCount;}
diff --git a/connectivity/source/inc/java/tools.hxx b/connectivity/source/inc/java/tools.hxx
index 8fe534bbbad9..ba7496c2e575 100644
--- a/connectivity/source/inc/java/tools.hxx
+++ b/connectivity/source/inc/java/tools.hxx
@@ -42,7 +42,7 @@ namespace connectivity
/// @throws css::sdbc::SQLException
/// @throws css::uno::RuntimeException
- java_util_Properties* createStringPropertyArray(const css::uno::Sequence< css::beans::PropertyValue >& info );
+ std::unique_ptr<java_util_Properties> createStringPropertyArray(const css::uno::Sequence< css::beans::PropertyValue >& info );
jobject convertTypeMapToJavaMap(const css::uno::Reference< css::container::XNameAccess > & _rMap);