diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-03 15:03:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-07 08:32:14 +0200 |
commit | 6e155026b1c123045def6e1a72ac268e78b4262e (patch) | |
tree | 9b2f24e03d8a5da00d2ce630aa382cccc2126f07 | |
parent | 619027af4480e71198ab7c642f9b56c618c1fba3 (diff) |
loplugin:useuniqueptr in GIFLZWCompressor
Change-Id: Iffc9cab9717691818bdc49c8a97f0dff9461340d
Reviewed-on: https://gerrit.libreoffice.org/53871
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | filter/source/graphicfilter/egif/giflzwc.cxx | 15 | ||||
-rw-r--r-- | filter/source/graphicfilter/egif/giflzwc.hxx | 4 |
2 files changed, 9 insertions, 10 deletions
diff --git a/filter/source/graphicfilter/egif/giflzwc.cxx b/filter/source/graphicfilter/egif/giflzwc.cxx index a660007c7a36..5a4601d38c9e 100644 --- a/filter/source/graphicfilter/egif/giflzwc.cxx +++ b/filter/source/graphicfilter/egif/giflzwc.cxx @@ -139,8 +139,8 @@ void GIFLZWCompressor::StartCompression( SvStream& rGIF, sal_uInt16 nPixelSize ) nTableSize=nEOICode+1; nCodeSize=nDataSize+1; - pIDOS=new GIFImageDataOutputStream(rGIF,static_cast<sal_uInt8>(nDataSize)); - pTable=new GIFLZWCTreeNode[4096]; + pIDOS.reset(new GIFImageDataOutputStream(rGIF,static_cast<sal_uInt8>(nDataSize))); + pTable.reset(new GIFLZWCTreeNode[4096]); for (i=0; i<4096; i++) { @@ -163,7 +163,7 @@ void GIFLZWCompressor::Compress(sal_uInt8* pSrc, sal_uInt32 nSize) if( !pPrefix && nSize ) { - pPrefix=pTable+(*pSrc++); + pPrefix=&pTable[*pSrc++]; nSize--; } @@ -198,14 +198,14 @@ void GIFLZWCompressor::Compress(sal_uInt8* pSrc, sal_uInt32 nSize) if(nTableSize==static_cast<sal_uInt16>(1<<nCodeSize)) nCodeSize++; - p=pTable+(nTableSize++); + p=&pTable[nTableSize++]; p->pBrother=pPrefix->pFirstChild; pPrefix->pFirstChild=p; p->nValue=nV; p->pFirstChild=nullptr; } - pPrefix=pTable+nV; + pPrefix=&pTable[nV]; } } } @@ -219,9 +219,8 @@ void GIFLZWCompressor::EndCompression() pIDOS->WriteBits(pPrefix->nCode,nCodeSize); pIDOS->WriteBits( nEOICode,nCodeSize ); - delete[] pTable; - delete pIDOS; - pIDOS=nullptr; + pTable.reset(); + pIDOS.reset(); } } diff --git a/filter/source/graphicfilter/egif/giflzwc.hxx b/filter/source/graphicfilter/egif/giflzwc.hxx index 0c51ff55d7b8..018a45812646 100644 --- a/filter/source/graphicfilter/egif/giflzwc.hxx +++ b/filter/source/graphicfilter/egif/giflzwc.hxx @@ -31,8 +31,8 @@ class GIFLZWCompressor { private: - GIFImageDataOutputStream* pIDOS; - GIFLZWCTreeNode* pTable; + std::unique_ptr<GIFImageDataOutputStream> pIDOS; + std::unique_ptr<GIFLZWCTreeNode[]> pTable; GIFLZWCTreeNode* pPrefix; sal_uInt16 nDataSize; sal_uInt16 nClearCode; |