[Libreoffice-commits] core.git: sc/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Jul 12 08:24:23 UTC 2018
sc/source/filter/inc/XclExpChangeTrack.hxx | 4 ++--
sc/source/filter/xcl97/XclExpChangeTrack.cxx | 11 +++++------
2 files changed, 7 insertions(+), 8 deletions(-)
New commits:
commit 592eb9217a52632e4271db3628c5aafb0cefbee8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Jul 11 12:24:18 2018 +0200
loplugin:useuniqueptr in XclExpChTrTabId
and write the buffer in one go in SaveCont
Change-Id: Id41bb132ff3b4176b1fcb1798d10191c3d45fffc
Reviewed-on: https://gerrit.libreoffice.org/57298
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/filter/inc/XclExpChangeTrack.hxx b/sc/source/filter/inc/XclExpChangeTrack.hxx
index 2f5eed82b3da..b20c1e167b21 100644
--- a/sc/source/filter/inc/XclExpChangeTrack.hxx
+++ b/sc/source/filter/inc/XclExpChangeTrack.hxx
@@ -319,10 +319,10 @@ public:
class XclExpChTrTabId : public ExcRecord
{
private:
- sal_uInt16* pBuffer;
+ std::unique_ptr<sal_uInt16> pBuffer;
sal_uInt16 nTabCount;
- void Clear() { delete[] pBuffer; pBuffer = nullptr; }
+ void Clear() { pBuffer.reset(); }
virtual void SaveCont( XclExpStream& rStrm ) override;
diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
index cde364769a7e..3035a774ac36 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -609,8 +609,8 @@ void XclExpChTrTabIdBuffer::Remove()
XclExpChTrTabId::XclExpChTrTabId( const XclExpChTrTabIdBuffer& rBuffer )
: nTabCount( rBuffer.GetBufferCount() )
{
- pBuffer = new sal_uInt16[ nTabCount ];
- rBuffer.GetBufferCopy( pBuffer );
+ pBuffer.reset( new sal_uInt16[ nTabCount ] );
+ rBuffer.GetBufferCopy( pBuffer.get() );
}
XclExpChTrTabId::~XclExpChTrTabId()
@@ -622,16 +622,15 @@ void XclExpChTrTabId::Copy( const XclExpChTrTabIdBuffer& rBuffer )
{
Clear();
nTabCount = rBuffer.GetBufferCount();
- pBuffer = new sal_uInt16[ nTabCount ];
- rBuffer.GetBufferCopy( pBuffer );
+ pBuffer.reset( new sal_uInt16[ nTabCount ] );
+ rBuffer.GetBufferCopy( pBuffer.get() );
}
void XclExpChTrTabId::SaveCont( XclExpStream& rStrm )
{
rStrm.EnableEncryption();
if( pBuffer )
- for( sal_uInt16* pElem = pBuffer; pElem < (pBuffer + nTabCount); pElem++ )
- rStrm << *pElem;
+ rStrm.Write(pBuffer.get(), nTabCount);
else
for( sal_uInt16 nIndex = 1; nIndex <= nTabCount; nIndex++ )
rStrm << nIndex;
More information about the Libreoffice-commits
mailing list