summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-05-03 13:48:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-05-07 08:30:53 +0200
commit7baed0c028df4b5215557e8410467277d068021b (patch)
tree8a822d25bcaa1ccb8d0d86abb3368f18953a9eb8 /connectivity
parente2b72039c619b64235fc7cbf12ac40b6b968f984 (diff)
loplugin:useuniqueptr in OFileTable
Change-Id: I74f21220b71703a18d1ae85f5f50397355304153 Reviewed-on: https://gerrit.libreoffice.org/53863 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/dbase/DTable.cxx19
-rw-r--r--connectivity/source/drivers/file/FTable.cxx9
-rw-r--r--connectivity/source/inc/file/FTable.hxx2
3 files changed, 11 insertions, 19 deletions
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 87be422f133c..815d45ba4635 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -812,7 +812,7 @@ bool ODbaseTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns & _rCols, bool
if ( ( nByteOffset + nLen) > m_nBufferSize )
break; // length doesn't match buffer size.
- char *pData = reinterpret_cast<char *>(m_pBuffer + nByteOffset);
+ char *pData = reinterpret_cast<char *>(m_pBuffer.get() + nByteOffset);
if (nType == DataType::CHAR || nType == DataType::VARCHAR)
{
@@ -1458,7 +1458,7 @@ bool ODbaseTable::InsertRow(OValueRefVector& rRow, const Reference<XIndexAccess>
if (!AllocBuffer())
return false;
- memset(m_pBuffer, 0, m_aHeader.recordLength);
+ memset(m_pBuffer.get(), 0, m_aHeader.recordLength);
m_pBuffer[0] = ' ';
// Copy new row completely:
@@ -1518,7 +1518,7 @@ bool ODbaseTable::UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow, const
// position on desired record:
std::size_t nPos = m_aHeader.headerLength + static_cast<long>(m_nFilePos-1) * m_aHeader.recordLength;
m_pFileStream->Seek(nPos);
- m_pFileStream->ReadBytes(m_pBuffer, m_aHeader.recordLength);
+ m_pFileStream->ReadBytes(m_pBuffer.get(), m_aHeader.recordLength);
std::size_t nMemoFileSize( 0 );
if (HasMemoFields() && m_pMemoStream)
@@ -1793,7 +1793,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo
pIndex->Insert(m_nFilePos, thisColVal);
}
- char* pData = reinterpret_cast<char *>(m_pBuffer + nByteOffset);
+ char* pData = reinterpret_cast<char *>(m_pBuffer.get() + nByteOffset);
if (thisColIsNull)
{
if ( bSetZero )
@@ -2591,7 +2591,7 @@ bool ODbaseTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32
if (m_pFileStream->GetError() != ERRCODE_NONE)
goto Error;
- std::size_t nRead = m_pFileStream->ReadBytes(m_pBuffer, nEntryLen);
+ std::size_t nRead = m_pFileStream->ReadBytes(m_pBuffer.get(), nEntryLen);
if (nRead != nEntryLen)
{
SAL_WARN("connectivity.drivers", "ODbaseTable::seekRow: short read!");
@@ -2710,15 +2710,14 @@ bool ODbaseTable::AllocBuffer()
if (m_nBufferSize != nSize)
{
- delete m_pBuffer;
- m_pBuffer = nullptr;
+ m_pBuffer.reset();
}
// if there is no buffer available: allocate:
- if (m_pBuffer == nullptr && nSize > 0)
+ if (!m_pBuffer && nSize > 0)
{
m_nBufferSize = nSize;
- m_pBuffer = new sal_uInt8[m_nBufferSize+1];
+ m_pBuffer.reset(new sal_uInt8[m_nBufferSize+1]);
}
return m_pBuffer != nullptr;
@@ -2731,7 +2730,7 @@ bool ODbaseTable::WriteBuffer()
// position on desired record:
std::size_t nPos = m_aHeader.headerLength + static_cast<long>(m_nFilePos-1) * m_aHeader.recordLength;
m_pFileStream->Seek(nPos);
- return m_pFileStream->WriteBytes(m_pBuffer, m_aHeader.recordLength) > 0;
+ return m_pFileStream->WriteBytes(m_pBuffer.get(), m_aHeader.recordLength) > 0;
}
sal_Int32 ODbaseTable::getCurrentLastPos() const
diff --git a/connectivity/source/drivers/file/FTable.cxx b/connectivity/source/drivers/file/FTable.cxx
index 6358874f93f7..e583e20db9af 100644
--- a/connectivity/source/drivers/file/FTable.cxx
+++ b/connectivity/source/drivers/file/FTable.cxx
@@ -40,7 +40,6 @@ OFileTable::OFileTable(sdbcx::OCollection* _pTables,OConnection* _pConnection)
,m_pConnection(_pConnection)
,m_pFileStream(nullptr)
,m_nFilePos(0)
- ,m_pBuffer(nullptr)
,m_nBufferSize(0)
,m_bWriteable(false)
{
@@ -63,7 +62,6 @@ OFileTable::OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection,
, m_pConnection(_pConnection)
, m_pFileStream(nullptr)
, m_nFilePos(0)
- , m_pBuffer(nullptr)
, m_nBufferSize(0)
, m_bWriteable(false)
{
@@ -156,12 +154,7 @@ void OFileTable::FileClose()
m_pFileStream->Flush();
m_pFileStream.reset();
-
- if (m_pBuffer)
- {
- delete[] m_pBuffer;
- m_pBuffer = nullptr;
- }
+ m_pBuffer.reset();
}
bool OFileTable::InsertRow(OValueRefVector& /*rRow*/, const css::uno::Reference< css::container::XIndexAccess>& /*_xCols*/)
diff --git a/connectivity/source/inc/file/FTable.hxx b/connectivity/source/inc/file/FTable.hxx
index 3495c79c24c9..bd12eca69eee 100644
--- a/connectivity/source/inc/file/FTable.hxx
+++ b/connectivity/source/inc/file/FTable.hxx
@@ -42,7 +42,7 @@ namespace connectivity
std::unique_ptr<SvStream> m_pFileStream;
::rtl::Reference<OSQLColumns> m_aColumns;
sal_Int32 m_nFilePos; // current IResultSetHelper::Movement
- sal_uInt8* m_pBuffer;
+ std::unique_ptr<sal_uInt8[]> m_pBuffer;
sal_uInt16 m_nBufferSize; // size of the ReadBuffer, if pBuffer != NULL
bool m_bWriteable; // svstream can't say if we are writeable
// so we have to