summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-01-10 12:30:15 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-01-11 12:47:37 +0100
commite57a036939e27ecd173ace691689e26a6a33df8e (patch)
treea36d589da272c4732cddb4ca0548cdb5dcb2b2bd /tools
parentcb5d79b504aa8575ea15c777707c7465ea43cb07 (diff)
loplugin:useuniqueptr in tools,stoc,unotools
Change-Id: Ia72b65577143623cedc7a40bc34f7fb897add097 Reviewed-on: https://gerrit.libreoffice.org/47726 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/inet/inetstrm.cxx10
-rw-r--r--tools/source/memtools/multisel.cxx150
-rw-r--r--tools/source/stream/stream.cxx40
-rw-r--r--tools/source/stream/strmunx.cxx6
-rw-r--r--tools/source/stream/strmwnt.cxx5
5 files changed, 89 insertions, 122 deletions
diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx
index 7949b5f94108..4c3015bf6cd0 100644
--- a/tools/source/inet/inetstrm.cxx
+++ b/tools/source/inet/inetstrm.cxx
@@ -79,7 +79,7 @@ int INetMIMEMessageStream::GetBodyLine(sal_Char* pData, sal_uInt32 nSize)
if (pSourceMsg->GetDocumentLB())
{
if (pMsgStrm == nullptr)
- pMsgStrm = new SvStream (pSourceMsg->GetDocumentLB());
+ pMsgStrm.reset(new SvStream (pSourceMsg->GetDocumentLB()));
sal_uInt32 nRead = pMsgStrm->ReadBytes(pWBuf, (pWEnd - pWBuf));
pWBuf += nRead;
@@ -156,7 +156,7 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uInt32 nSize)
nChildIndex++;
// Create child stream.
- pChildStrm = new INetMIMEMessageStream(pChild, false);
+ pChildStrm.reset(new INetMIMEMessageStream(pChild, false));
if (pSourceMsg->IsMultipart())
{
@@ -200,8 +200,7 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uInt32 nSize)
else
{
// Cleanup exhausted child stream.
- delete pChildStrm;
- pChildStrm = nullptr;
+ pChildStrm.reset();
}
}
}
@@ -248,8 +247,7 @@ INetMIMEMessageStream::INetMIMEMessageStream(
INetMIMEMessageStream::~INetMIMEMessageStream()
{
- delete pChildStrm;
- delete pMsgStrm;
+ pChildStrm.reset();
}
int INetMIMEMessageStream::Read(sal_Char* pData, sal_uInt32 nSize)
diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx
index d53ce8004e9c..b1dd66680ae6 100644
--- a/tools/source/memtools/multisel.cxx
+++ b/tools/source/memtools/multisel.cxx
@@ -26,10 +26,6 @@ void MultiSelection::ImplClear()
{
// no selected indexes
nSelCount = 0;
-
- for (Range* pSel : aSels) {
- delete pSel;
- }
aSels.clear();
}
@@ -38,7 +34,7 @@ sal_Int32 MultiSelection::ImplFindSubSelection( sal_Int32 nIndex ) const
// iterate through the sub selections
sal_Int32 n = 0;
for ( ;
- n < sal_Int32(aSels.size()) && nIndex > aSels[ n ]->Max();
+ n < sal_Int32(aSels.size()) && nIndex > aSels[ n ].Max();
++n ) {} /* empty loop */
return n;
}
@@ -50,14 +46,11 @@ void MultiSelection::ImplMergeSubSelections( sal_Int32 nPos1, sal_Int32 nPos2 )
return;
// did the sub selections touch each other?
- if ( (aSels[ nPos1 ]->Max() + 1) == aSels[ nPos2 ]->Min() )
+ if ( (aSels[ nPos1 ].Max() + 1) == aSels[ nPos2 ].Min() )
{
// merge them
- aSels[ nPos1 ]->Max() = aSels[ nPos2 ]->Max();
- ImpSelList::iterator it = aSels.begin();
- ::std::advance( it, nPos2 );
- delete *it;
- aSels.erase( it );
+ aSels[ nPos1 ].Max() = aSels[ nPos2 ].Max();
+ aSels.erase( aSels.begin() + nPos2 );
}
}
@@ -95,8 +88,8 @@ MultiSelection::MultiSelection( const MultiSelection& rOrig ) :
}
// copy the sub selections
- for (const Range* pSel : rOrig.aSels)
- aSels.push_back( new Range( *pSel ) );
+ for (const Range & rSel : rOrig.aSels)
+ aSels.push_back( rSel );
}
MultiSelection::MultiSelection( const Range& rRange ):
@@ -110,9 +103,6 @@ MultiSelection::MultiSelection( const Range& rRange ):
MultiSelection::~MultiSelection()
{
- for (Range* pSel : aSels)
- delete pSel;
- aSels.clear();
}
MultiSelection& MultiSelection::operator= ( const MultiSelection& rOrig )
@@ -127,8 +117,8 @@ MultiSelection& MultiSelection::operator= ( const MultiSelection& rOrig )
// clear the old and copy the sub selections
ImplClear();
- for (const Range* pSel : rOrig.aSels)
- aSels.push_back( new Range( *pSel ) );
+ for (const Range& rSel : rOrig.aSels)
+ aSels.push_back( rSel );
nSelCount = rOrig.nSelCount;
return *this;
@@ -139,7 +129,7 @@ void MultiSelection::SelectAll( bool bSelect )
ImplClear();
if ( bSelect )
{
- aSels.push_back( new Range(aTotRange) );
+ aSels.push_back( aTotRange );
nSelCount = aTotRange.Len();
}
}
@@ -158,7 +148,7 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect )
if ( bSelect )
{
// is it included in the found sub selection?
- if ( nSubSelPos < sal_Int32(aSels.size()) && aSels[ nSubSelPos ]->IsInside( nIndex ) )
+ if ( nSubSelPos < sal_Int32(aSels.size()) && aSels[ nSubSelPos ].IsInside( nIndex ) )
// already selected, nothing to do
return false;
@@ -167,29 +157,27 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect )
// is it at the end of the previous sub selection
if ( nSubSelPos > 0 &&
- aSels[ nSubSelPos-1 ]->Max() == (nIndex-1) )
+ aSels[ nSubSelPos-1 ].Max() == (nIndex-1) )
{
// expand the previous sub selection
- aSels[ nSubSelPos-1 ]->Max() = nIndex;
+ aSels[ nSubSelPos-1 ].Max() = nIndex;
// try to merge the previous sub selection
ImplMergeSubSelections( nSubSelPos-1, nSubSelPos );
}
// is it at the beginning of the found sub selection
else if ( nSubSelPos < sal_Int32(aSels.size())
- && aSels[ nSubSelPos ]->Min() == (nIndex+1)
+ && aSels[ nSubSelPos ].Min() == (nIndex+1)
)
// expand the found sub selection
- aSels[ nSubSelPos ]->Min() = nIndex;
+ aSels[ nSubSelPos ].Min() = nIndex;
else
{
// create a new sub selection
if ( nSubSelPos < sal_Int32(aSels.size()) ) {
- ImpSelList::iterator it = aSels.begin();
- ::std::advance( it, nSubSelPos );
- aSels.insert( it, new Range( nIndex, nIndex ) );
+ aSels.insert( aSels.begin() + nSubSelPos, Range( nIndex, nIndex ) );
} else {
- aSels.push_back( new Range( nIndex, nIndex ) );
+ aSels.push_back( Range( nIndex, nIndex ) );
}
if ( bCurValid && nCurSubSel >= nSubSelPos )
++nCurSubSel;
@@ -199,7 +187,7 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect )
{
// is it excluded from the found sub selection?
if ( nSubSelPos >= sal_Int32(aSels.size())
- || !aSels[ nSubSelPos ]->IsInside( nIndex )
+ || !aSels[ nSubSelPos ].IsInside( nIndex )
) {
// not selected, nothing to do
return false;
@@ -209,34 +197,29 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect )
--nSelCount;
// is it the only index in the found sub selection?
- if ( aSels[ nSubSelPos ]->Len() == 1 )
+ if ( aSels[ nSubSelPos ].Len() == 1 )
{
// remove the complete sub selection
- ImpSelList::iterator it = aSels.begin();
- ::std::advance( it, nSubSelPos );
- delete *it;
- aSels.erase( it );
+ aSels.erase( aSels.begin() + nSubSelPos );
return true;
}
// is it at the beginning of the found sub selection?
- if ( aSels[ nSubSelPos ]->Min() == nIndex )
- ++aSels[ nSubSelPos ]->Min();
+ if ( aSels[ nSubSelPos ].Min() == nIndex )
+ ++aSels[ nSubSelPos ].Min();
// is it at the end of the found sub selection?
- else if ( aSels[ nSubSelPos ]->Max() == nIndex )
- --aSels[ nSubSelPos ]->Max();
+ else if ( aSels[ nSubSelPos ].Max() == nIndex )
+ --aSels[ nSubSelPos ].Max();
// it is in the middle of the found sub selection?
else
{
// split the sub selection
if ( nSubSelPos < sal_Int32(aSels.size()) ) {
- ImpSelList::iterator it = aSels.begin();
- ::std::advance( it, nSubSelPos );
- aSels.insert( it, new Range( aSels[ nSubSelPos ]->Min(), nIndex-1 ) );
+ aSels.insert( aSels.begin() + nSubSelPos, Range( aSels[ nSubSelPos ].Min(), nIndex-1 ) );
} else {
- aSels.push_back( new Range( aSels[ nSubSelPos ]->Min(), nIndex-1 ) );
+ aSels.push_back( Range( aSels[ nSubSelPos ].Min(), nIndex-1 ) );
}
- aSels[ nSubSelPos+1 ]->Min() = nIndex + 1;
+ aSels[ nSubSelPos+1 ].Min() = nIndex + 1;
}
}
@@ -245,7 +228,6 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect )
void MultiSelection::Select( const Range& rIndexRange, bool bSelect )
{
- Range* pRange;
sal_Int32 nOld;
sal_Int32 nTmpMin = rIndexRange.Min();
@@ -261,7 +243,7 @@ void MultiSelection::Select( const Range& rIndexRange, bool bSelect )
ImplClear();
if ( bSelect )
{
- aSels.push_back( new Range(rIndexRange) );
+ aSels.push_back( rIndexRange );
nSelCount = rIndexRange.Len();
}
return;
@@ -274,15 +256,14 @@ void MultiSelection::Select( const Range& rIndexRange, bool bSelect )
// extend first range?
if( nCurMin > (nTmpMax+1) )
{
- pRange = new Range( rIndexRange );
- aSels.insert( aSels.begin() , pRange );
- nSelCount += pRange->Len();
+ aSels.insert( aSels.begin(), rIndexRange );
+ nSelCount += rIndexRange.Len();
}
else
{
- pRange = aSels.front();
- nOld = pRange->Min();
- pRange->Min() = nTmpMin;
+ auto & rRange = aSels.front();
+ nOld = rRange.Min();
+ rRange.Min() = nTmpMin;
nSelCount += ( nOld - nTmpMin );
}
bCurValid = false;
@@ -297,15 +278,14 @@ void MultiSelection::Select( const Range& rIndexRange, bool bSelect )
// extend last range?
if( nTmpMin > (nCurMax+1) )
{
- pRange = new Range( rIndexRange );
- aSels.push_back( pRange );
- nSelCount += pRange->Len();
+ aSels.push_back( rIndexRange );
+ nSelCount += rIndexRange.Len();
}
else
{
- pRange = aSels.back();
- nOld = pRange->Max();
- pRange->Max() = nTmpMax;
+ auto & rRange = aSels.back();
+ nOld = rRange.Max();
+ rRange.Max() = nTmpMax;
nSelCount += ( nTmpMax - nOld );
}
bCurValid = false;
@@ -326,7 +306,7 @@ bool MultiSelection::IsSelected( sal_Int32 nIndex ) const
// find the virtual target position
sal_Int32 nSubSelPos = ImplFindSubSelection( nIndex );
- return nSubSelPos < sal_Int32(aSels.size()) && aSels[ nSubSelPos ]->IsInside(nIndex);
+ return nSubSelPos < sal_Int32(aSels.size()) && aSels[ nSubSelPos ].IsInside(nIndex);
}
void MultiSelection::Insert( sal_Int32 nIndex, sal_Int32 nCount )
@@ -337,25 +317,23 @@ void MultiSelection::Insert( sal_Int32 nIndex, sal_Int32 nCount )
// did we need to shift the sub selections?
if ( nSubSelPos < sal_Int32(aSels.size()) )
{ // did we insert an unselected into an existing sub selection?
- if ( aSels[ nSubSelPos ]->Min() != nIndex
- && aSels[ nSubSelPos ]->IsInside(nIndex)
+ if ( aSels[ nSubSelPos ].Min() != nIndex
+ && aSels[ nSubSelPos ].IsInside(nIndex)
) { // split the sub selection
if ( nSubSelPos < sal_Int32(aSels.size()) ) {
- ImpSelList::iterator it = aSels.begin();
- ::std::advance( it, nSubSelPos );
- aSels.insert( it, new Range( aSels[ nSubSelPos ]->Min(), nIndex-1 ) );
+ aSels.insert( aSels.begin() + nSubSelPos, Range( aSels[ nSubSelPos ].Min(), nIndex-1 ) );
} else {
- aSels.push_back( new Range( aSels[ nSubSelPos ]->Min(), nIndex-1 ) );
+ aSels.push_back( Range( aSels[ nSubSelPos ].Min(), nIndex-1 ) );
}
++nSubSelPos;
- aSels[ nSubSelPos ]->Min() = nIndex;
+ aSels[ nSubSelPos ].Min() = nIndex;
}
// shift the sub selections behind the inserting position
for ( sal_Int32 nPos = nSubSelPos; nPos < sal_Int32(aSels.size()); ++nPos )
{
- aSels[ nPos ]->Min() += nCount;
- aSels[ nPos ]->Max() += nCount;
+ aSels[ nPos ].Min() += nCount;
+ aSels[ nPos ].Max() += nCount;
}
}
@@ -370,18 +348,15 @@ void MultiSelection::Remove( sal_Int32 nIndex )
// did we remove from an existing sub selection?
if ( nSubSelPos < sal_Int32(aSels.size())
- && aSels[ nSubSelPos ]->IsInside(nIndex)
+ && aSels[ nSubSelPos ].IsInside(nIndex)
) {
// does this sub selection only contain the index to be deleted
- if ( aSels[ nSubSelPos ]->Len() == 1 ) {
+ if ( aSels[ nSubSelPos ].Len() == 1 ) {
// completely remove the sub selection
- ImpSelList::iterator it = aSels.begin();
- ::std::advance( it, nSubSelPos );
- delete *it;
- aSels.erase( it );
+ aSels.erase( aSels.begin() + nSubSelPos );
} else {
// shorten this sub selection
- --( aSels[ nSubSelPos++ ]->Max() );
+ --( aSels[ nSubSelPos++ ].Max() );
}
// adjust the selected counter
@@ -391,8 +366,8 @@ void MultiSelection::Remove( sal_Int32 nIndex )
// shift the sub selections behind the removed index
for ( sal_Int32 nPos = nSubSelPos; nPos < sal_Int32(aSels.size()); ++nPos )
{
- --( aSels[ nPos ]->Min() );
- --( aSels[ nPos ]->Max() );
+ --( aSels[ nPos ].Min() );
+ --( aSels[ nPos ].Max() );
}
bCurValid = false;
@@ -405,9 +380,9 @@ sal_Int32 MultiSelection::ImplFwdUnselected()
return SFX_ENDOFSELECTION;
if ( ( nCurSubSel < sal_Int32(aSels.size()) )
- && ( aSels[ nCurSubSel ]->Min() <= nCurIndex )
+ && ( aSels[ nCurSubSel ].Min() <= nCurIndex )
)
- nCurIndex = aSels[ nCurSubSel++ ]->Max() + 1;
+ nCurIndex = aSels[ nCurSubSel++ ].Max() + 1;
if ( nCurIndex <= aTotRange.Max() )
return nCurIndex;
@@ -421,7 +396,7 @@ sal_Int32 MultiSelection::FirstSelected()
bCurValid = !aSels.empty();
if ( bCurValid )
- return nCurIndex = aSels[ 0 ]->Min();
+ return nCurIndex = aSels[ 0 ].Min();
return SFX_ENDOFSELECTION;
}
@@ -432,7 +407,7 @@ sal_Int32 MultiSelection::LastSelected()
bCurValid = !aSels.empty();
if ( bCurValid )
- return nCurIndex = aSels[ nCurSubSel ]->Max();
+ return nCurIndex = aSels[ nCurSubSel ].Max();
return SFX_ENDOFSELECTION;
}
@@ -443,12 +418,12 @@ sal_Int32 MultiSelection::NextSelected()
return SFX_ENDOFSELECTION;
// is the next index in the current sub selection too?
- if ( nCurIndex < aSels[ nCurSubSel ]->Max() )
+ if ( nCurIndex < aSels[ nCurSubSel ].Max() )
return ++nCurIndex;
// are there further sub selections?
if ( ++nCurSubSel < sal_Int32(aSels.size()) )
- return nCurIndex = aSels[ nCurSubSel ]->Min();
+ return nCurIndex = aSels[ nCurSubSel ].Min();
// we are at the end!
return SFX_ENDOFSELECTION;
@@ -459,7 +434,7 @@ void MultiSelection::SetTotalRange( const Range& rTotRange )
aTotRange = rTotRange;
// adjust lower boundary
- Range* pRange = aSels.empty() ? nullptr : aSels.front();
+ Range* pRange = aSels.empty() ? nullptr : &aSels.front();
while( pRange )
{
if( pRange->Max() < aTotRange.Min() )
@@ -475,17 +450,16 @@ void MultiSelection::SetTotalRange( const Range& rTotRange )
else
break;
- pRange = aSels.empty() ? nullptr : aSels.front();
+ pRange = aSels.empty() ? nullptr : &aSels.front();
}
// adjust upper boundary
sal_Int32 nCount = aSels.size();
while( nCount )
{
- pRange = aSels[ nCount - 1 ];
+ pRange = &aSels[ nCount - 1 ];
if( pRange->Min() > aTotRange.Max() )
{
- delete pRange;
aSels.pop_back();
}
else if( pRange->Max() > aTotRange.Max() )
@@ -501,8 +475,8 @@ void MultiSelection::SetTotalRange( const Range& rTotRange )
// re-calculate selection count
nSelCount = 0;
- for (Range* pSel : aSels)
- nSelCount += pSel->Len();
+ for (Range const & rSel : aSels)
+ nSelCount += rSel.Len();
bCurValid = false;
nCurIndex = 0;
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 516cfd18a51a..c7d1e3f8414a 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -368,8 +368,6 @@ SvStream::~SvStream()
{
if (m_xLockBytes.is())
Flush();
-
- delete[] m_pRWBuf;
}
void SvStream::ClearError()
@@ -407,7 +405,7 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize )
if (m_nBufSize)
{
- delete[] m_pRWBuf;
+ m_pRWBuf.reset();
m_nBufFilePos += m_nBufActualPos;
}
@@ -416,9 +414,9 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize )
m_nBufActualPos = 0;
m_nBufSize = nBufferSize;
if (m_nBufSize)
- m_pRWBuf = new sal_uInt8[ m_nBufSize ];
+ m_pRWBuf.reset(new sal_uInt8[ m_nBufSize ]);
m_isConsistent = true;
- m_pBufPos = m_pRWBuf;
+ m_pBufPos = m_pRWBuf.get();
m_isIoRead = m_isIoWrite = false;
if( !bDontSeek )
SeekPos( nActualFilePos );
@@ -429,7 +427,7 @@ void SvStream::ClearBuffer()
m_nBufActualLen = 0;
m_nBufActualPos = 0;
m_nBufFilePos = 0;
- m_pBufPos = m_pRWBuf;
+ m_pBufPos = m_pRWBuf.get();
m_isDirty = false;
m_isConsistent = true;
m_isIoRead = m_isIoWrite = false;
@@ -809,7 +807,7 @@ sal_uInt64 SvStream::SeekRel(sal_Int64 const nPos)
nActualPos -= nAbsPos;
}
- m_pBufPos = m_pRWBuf + nActualPos;
+ m_pBufPos = m_pRWBuf.get() + nActualPos;
return Seek( nActualPos );
}
@@ -1225,8 +1223,8 @@ void SvStream::FlushBuffer(bool isConsistent)
{
SeekPos(m_nBufFilePos);
if (m_nCryptMask)
- CryptAndWriteBuffer(m_pRWBuf, m_nBufActualLen);
- else if (PutData(m_pRWBuf, m_nBufActualLen) != m_nBufActualLen)
+ CryptAndWriteBuffer(m_pRWBuf.get(), m_nBufActualLen);
+ else if (PutData(m_pRWBuf.get(), m_nBufActualLen) != m_nBufActualLen)
SetError(SVSTREAM_WRITE_ERROR);
m_isDirty = false;
}
@@ -1273,7 +1271,7 @@ std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount )
SeekPos(m_nBufFilePos + m_nBufActualPos);
m_nBufActualLen = 0;
- m_pBufPos = m_pRWBuf;
+ m_pBufPos = m_pRWBuf.get();
nCount = GetData( pData, nCount );
if (m_nCryptMask)
EncryptBuffer(pData, nCount);
@@ -1289,17 +1287,17 @@ std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount )
SeekPos(m_nBufFilePos);
// TODO: Typecast before GetData, sal_uInt16 nCountTmp
- std::size_t nCountTmp = GetData( m_pRWBuf, m_nBufSize );
+ std::size_t nCountTmp = GetData( m_pRWBuf.get(), m_nBufSize );
if (m_nCryptMask)
- EncryptBuffer(m_pRWBuf, nCountTmp);
+ EncryptBuffer(m_pRWBuf.get(), nCountTmp);
m_nBufActualLen = (sal_uInt16)nCountTmp;
if( nCount > nCountTmp )
{
nCount = nCountTmp; // trim count back, EOF see below
}
- memcpy( pData, m_pRWBuf, (size_t)nCount );
+ memcpy( pData, m_pRWBuf.get(), (size_t)nCount );
m_nBufActualPos = (sal_uInt16)nCount;
- m_pBufPos = m_pRWBuf + nCount;
+ m_pBufPos = m_pRWBuf.get() + nCount;
}
}
}
@@ -1359,7 +1357,7 @@ std::size_t SvStream::WriteBytes( const void* pData, std::size_t nCount )
m_nBufFilePos += m_nBufActualPos;
m_nBufActualLen = 0;
m_nBufActualPos = 0;
- m_pBufPos = m_pRWBuf;
+ m_pBufPos = m_pRWBuf.get();
SeekPos(m_nBufFilePos);
if (m_nCryptMask)
nCount = CryptAndWriteBuffer( pData, nCount );
@@ -1370,12 +1368,12 @@ std::size_t SvStream::WriteBytes( const void* pData, std::size_t nCount )
else
{
// Copy block to buffer
- memcpy( m_pRWBuf, pData, (size_t)nCount );
+ memcpy( m_pRWBuf.get(), pData, (size_t)nCount );
// Mind the order!
m_nBufFilePos += m_nBufActualPos;
m_nBufActualPos = (sal_uInt16)nCount;
- m_pBufPos = m_pRWBuf + nCount;
+ m_pBufPos = m_pRWBuf.get() + nCount;
m_nBufActualLen = (sal_uInt16)nCount;
m_isDirty = true;
}
@@ -1399,7 +1397,7 @@ sal_uInt64 SvStream::Seek(sal_uInt64 const nFilePos)
if (nFilePos >= m_nBufFilePos && nFilePos <= (m_nBufFilePos + m_nBufActualLen))
{
m_nBufActualPos = (sal_uInt16)(nFilePos - m_nBufFilePos);
- m_pBufPos = m_pRWBuf + m_nBufActualPos;
+ m_pBufPos = m_pRWBuf.get() + m_nBufActualPos;
// Update m_nBufFree to avoid crash upon PutBack
m_nBufFree = m_nBufActualLen - m_nBufActualPos;
}
@@ -1408,7 +1406,7 @@ sal_uInt64 SvStream::Seek(sal_uInt64 const nFilePos)
FlushBuffer(m_isConsistent);
m_nBufActualLen = 0;
m_nBufActualPos = 0;
- m_pBufPos = m_pRWBuf;
+ m_pBufPos = m_pRWBuf.get();
m_nBufFilePos = SeekPos( nFilePos );
}
return m_nBufFilePos + m_nBufActualPos;
@@ -1443,11 +1441,11 @@ void SvStream::RefreshBuffer()
{
FlushBuffer(m_isConsistent);
SeekPos(m_nBufFilePos);
- m_nBufActualLen = (sal_uInt16)GetData( m_pRWBuf, m_nBufSize );
+ m_nBufActualLen = (sal_uInt16)GetData( m_pRWBuf.get(), m_nBufSize );
if (m_nBufActualLen && m_nError == ERRCODE_IO_PENDING)
m_nError = ERRCODE_NONE;
if (m_nCryptMask)
- EncryptBuffer(m_pRWBuf, (std::size_t)m_nBufActualLen);
+ EncryptBuffer(m_pRWBuf.get(), (std::size_t)m_nBufActualLen);
m_isConsistent = true;
m_isIoRead = m_isIoWrite = false;
}
diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index d3f79e6c3712..d06544e72031 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -273,7 +273,7 @@ SvFileStream::SvFileStream( const OUString& rFileName, StreamMode nOpenMode )
{
bIsOpen = false;
m_isWritable = false;
- pInstanceData = new StreamData;
+ pInstanceData.reset(new StreamData);
SetBufferSize( 1024 );
// convert URL to SystemPath, if necessary
@@ -290,15 +290,13 @@ SvFileStream::SvFileStream()
{
bIsOpen = false;
m_isWritable = false;
- pInstanceData = new StreamData;
+ pInstanceData.reset(new StreamData);
SetBufferSize( 1024 );
}
SvFileStream::~SvFileStream()
{
Close();
-
- delete pInstanceData;
}
std::size_t SvFileStream::GetData( void* pData, std::size_t nSize )
diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx
index 8a626ecc7c76..3b890fbfef1b 100644
--- a/tools/source/stream/strmwnt.cxx
+++ b/tools/source/stream/strmwnt.cxx
@@ -109,7 +109,7 @@ SvFileStream::SvFileStream( const OUString& rFileName, StreamMode nMode )
bIsOpen = false;
nLockCounter = 0;
m_isWritable = false;
- pInstanceData = new StreamData;
+ pInstanceData.reset( new StreamData );
SetBufferSize( 8192 );
// convert URL to SystemPath, if necessary
@@ -125,7 +125,7 @@ SvFileStream::SvFileStream()
bIsOpen = false;
nLockCounter = 0;
m_isWritable = false;
- pInstanceData = new StreamData;
+ pInstanceData.reset( new StreamData );
SetBufferSize( 8192 );
}
@@ -133,7 +133,6 @@ SvFileStream::SvFileStream()
SvFileStream::~SvFileStream()
{
Close();
- delete pInstanceData;
}
/// Does not check for EOF, makes isEof callable