summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-07-10 09:48:28 +0200
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-12-18 01:07:46 -0500
commit0c06cab09ec66cd8720d53ed7abde828d931142b (patch)
tree3cc4fd40c6db6852017c20eb3fbe00e3523f9edd
parente9f5dd68136329250544a4af123148136521a54d (diff)
loplugin:useuniqueptr in vcl
Reviewed-on: https://gerrit.libreoffice.org/39740 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit 804cd2bd56295c5cb039b55ac7ca880c17399bad) Change-Id: Ieece2f9728755a8ae91275535eaa39319eea274e (cherry picked from commit 6c43e557f28b09a9b0a18e69c0c7e6f8c93329b9)
-rw-r--r--vcl/headless/svpgdi.cxx21
-rw-r--r--vcl/inc/textlineinfo.hxx11
-rw-r--r--vcl/source/filter/igif/decode.cxx20
-rw-r--r--vcl/source/filter/igif/decode.hxx8
-rw-r--r--vcl/source/font/fontcharmap.cxx11
-rw-r--r--vcl/source/gdi/pngread.cxx84
-rw-r--r--vcl/source/outdev/text.cxx21
-rw-r--r--vcl/unx/generic/glyphs/freetype_glyphcache.cxx19
-rw-r--r--vcl/unx/generic/print/bitmap_gfx.cxx15
9 files changed, 93 insertions, 117 deletions
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index dc877627a21e..7eeea4edec50 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -170,16 +170,16 @@ namespace
// the alpha values need to be inverted for Cairo
// so big stupid copy and invert here
const int nImageSize = pMaskBuf->mnHeight * pMaskBuf->mnScanlineSize;
- pAlphaBits = new unsigned char[nImageSize];
- memcpy(pAlphaBits, pMaskBuf->mpBits, nImageSize);
+ pAlphaBits.reset( new unsigned char[nImageSize] );
+ memcpy(pAlphaBits.get(), pMaskBuf->mpBits, nImageSize);
// TODO: make upper layers use standard alpha
- sal_uInt32* pLDst = reinterpret_cast<sal_uInt32*>(pAlphaBits);
+ sal_uInt32* pLDst = reinterpret_cast<sal_uInt32*>(pAlphaBits.get());
for( int i = nImageSize/sizeof(sal_uInt32); --i >= 0; ++pLDst )
*pLDst = ~*pLDst;
- assert(reinterpret_cast<unsigned char*>(pLDst) == pAlphaBits+nImageSize);
+ assert(reinterpret_cast<unsigned char*>(pLDst) == pAlphaBits.get()+nImageSize);
- mask = cairo_image_surface_create_for_data(pAlphaBits,
+ mask = cairo_image_surface_create_for_data(pAlphaBits.get(),
CAIRO_FORMAT_A8,
pMaskBuf->mnWidth, pMaskBuf->mnHeight,
pMaskBuf->mnScanlineSize);
@@ -189,15 +189,15 @@ namespace
// the alpha values need to be inverted for Cairo
// so big stupid copy and invert here
const int nImageSize = pMaskBuf->mnHeight * pMaskBuf->mnScanlineSize;
- pAlphaBits = new unsigned char[nImageSize];
- memcpy(pAlphaBits, pMaskBuf->mpBits, nImageSize);
+ pAlphaBits.reset( new unsigned char[nImageSize] );
+ memcpy(pAlphaBits.get(), pMaskBuf->mpBits, nImageSize);
// TODO: make upper layers use standard alpha
- unsigned char* pDst = pAlphaBits;
+ unsigned char* pDst = pAlphaBits.get();
for (int i = nImageSize; --i >= 0; ++pDst)
*pDst = ~*pDst;
- mask = cairo_image_surface_create_for_data(pAlphaBits,
+ mask = cairo_image_surface_create_for_data(pAlphaBits.get(),
CAIRO_FORMAT_A1,
pMaskBuf->mnWidth, pMaskBuf->mnHeight,
pMaskBuf->mnScanlineSize);
@@ -206,7 +206,6 @@ namespace
~MaskHelper()
{
cairo_surface_destroy(mask);
- delete[] pAlphaBits;
}
cairo_surface_t* getMask()
{
@@ -214,7 +213,7 @@ namespace
}
private:
cairo_surface_t *mask;
- unsigned char* pAlphaBits;
+ std::unique_ptr<unsigned char[]> pAlphaBits;
MaskHelper(const MaskHelper&) = delete;
MaskHelper& operator=(const MaskHelper&) = delete;
diff --git a/vcl/inc/textlineinfo.hxx b/vcl/inc/textlineinfo.hxx
index a14d774b7a7a..18abde3e2b10 100644
--- a/vcl/inc/textlineinfo.hxx
+++ b/vcl/inc/textlineinfo.hxx
@@ -20,6 +20,9 @@
#ifndef INCLUDED_VCL_INC_TEXTLINEINFO_HXX
#define INCLUDED_VCL_INC_TEXTLINEINFO_HXX
+#include <memory>
+#include <vector>
+
class ImplTextLineInfo
{
private:
@@ -57,16 +60,14 @@ public:
void Clear();
ImplTextLineInfo* GetLine( sal_Int32 nLine ) const
- { return mpLines[nLine]; }
- sal_Int32 Count() const { return mnLines; }
+ { return mvLines[nLine].get(); }
+ sal_Int32 Count() const { return mvLines.size(); }
private:
ImplMultiTextLineInfo( const ImplMultiTextLineInfo& ) = delete;
ImplMultiTextLineInfo& operator=( const ImplMultiTextLineInfo& ) = delete;
- ImplTextLineInfo** mpLines;
- sal_Int32 mnLines;
- sal_Int32 mnSize;
+ std::vector<std::unique_ptr<ImplTextLineInfo>> mvLines;
};
diff --git a/vcl/source/filter/igif/decode.cxx b/vcl/source/filter/igif/decode.cxx
index 9647fc97ab3a..bbbbee27d10d 100644
--- a/vcl/source/filter/igif/decode.cxx
+++ b/vcl/source/filter/igif/decode.cxx
@@ -38,31 +38,27 @@ GIFLZWDecompressor::GIFLZWDecompressor(sal_uInt8 cDataSize)
, nBlockBufSize(0)
, nBlockBufPos(0)
{
- pOutBuf = new sal_uInt8[ 4096 ];
-
nClearCode = 1 << nDataSize;
nEOICode = nClearCode + 1;
nTableSize = nEOICode + 1;
nCodeSize = nDataSize + 1;
nOldCode = 0xffff;
- pOutBufData = pOutBuf + 4096;
+ pOutBufData = pOutBuf.data() + 4096;
- pTable = new GIFLZWTableEntry[ 4098 ];
+ pTable.reset( new GIFLZWTableEntry[ 4098 ] );
for (sal_uInt16 i = 0; i < nTableSize; ++i)
{
pTable[i].pPrev = nullptr;
- pTable[i].pFirst = pTable + i;
+ pTable[i].pFirst = pTable.get() + i;
pTable[i].nData = (sal_uInt8) i;
}
- memset(pTable + nTableSize, 0, sizeof(GIFLZWTableEntry) * (4098 - nTableSize));
+ memset(pTable.get() + nTableSize, 0, sizeof(GIFLZWTableEntry) * (4098 - nTableSize));
}
GIFLZWDecompressor::~GIFLZWDecompressor()
{
- delete[] pOutBuf;
- delete[] pTable;
}
Scanline GIFLZWDecompressor::DecompressBlock( sal_uInt8* pSrc, sal_uInt8 cBufSize,
@@ -113,8 +109,8 @@ bool GIFLZWDecompressor::AddToTable( sal_uInt16 nPrevCode, sal_uInt16 nCodeFirst
{
if( nTableSize < 4096 )
{
- GIFLZWTableEntry* pE = pTable + nTableSize;
- pE->pPrev = pTable + nPrevCode;
+ GIFLZWTableEntry* pE = pTable.get() + nTableSize;
+ pE->pPrev = pTable.get() + nPrevCode;
pE->pFirst = pE->pPrev->pFirst;
GIFLZWTableEntry *pEntry = pTable[nCodeFirstData].pFirst;
if (!pEntry)
@@ -196,10 +192,10 @@ bool GIFLZWDecompressor::ProcessOneCode()
return false;
// write character(/-sequence) of code nCode in the output buffer:
- GIFLZWTableEntry* pE = pTable + nCode;
+ GIFLZWTableEntry* pE = pTable.get() + nCode;
do
{
- if (pOutBufData == pOutBuf) //can't go back past start
+ if (pOutBufData == pOutBuf.data()) //can't go back past start
return false;
nOutBufDataLen++;
*(--pOutBufData) = pE->nData;
diff --git a/vcl/source/filter/igif/decode.hxx b/vcl/source/filter/igif/decode.hxx
index 0983958ef679..fb9d65527264 100644
--- a/vcl/source/filter/igif/decode.hxx
+++ b/vcl/source/filter/igif/decode.hxx
@@ -21,13 +21,17 @@
#define INCLUDED_VCL_SOURCE_FILTER_IGIF_DECODE_HXX
#include <vcl/bitmapaccess.hxx>
+#include <array>
+#include <memory>
struct GIFLZWTableEntry;
class GIFLZWDecompressor
{
- GIFLZWTableEntry* pTable;
- sal_uInt8* pOutBuf;
+ std::unique_ptr<GIFLZWTableEntry[]>
+ pTable;
+ std::array<sal_uInt8, 4096>
+ pOutBuf;
sal_uInt8* pOutBufData;
sal_uInt8* pBlockBuf;
sal_uLong nInputBitsBuf;
diff --git a/vcl/source/font/fontcharmap.cxx b/vcl/source/font/fontcharmap.cxx
index 61e2323703b9..273894641615 100644
--- a/vcl/source/font/fontcharmap.cxx
+++ b/vcl/source/font/fontcharmap.cxx
@@ -38,11 +38,12 @@ static const sal_UCS4 aDefaultSymbolRanges[] = {0x0020,0x0100, 0xF020,0xF100};
ImplFontCharMap::~ImplFontCharMap()
{
- if( isDefaultMap() )
- return;
- delete[] mpRangeCodes;
- delete[] mpStartGlyphs;
- delete[] mpGlyphIds;
+ if( !isDefaultMap() )
+ {
+ delete[] mpRangeCodes;
+ delete[] mpStartGlyphs;
+ delete[] mpGlyphIds;
+ }
}
ImplFontCharMap::ImplFontCharMap( const CmapResult& rCR )
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index 0dc5cfa1e053..6bf4e7fedc65 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -84,9 +84,12 @@ private:
BitmapWriteAccess* mpMaskAcc;
ZCodec mpZCodec;
- sal_uInt8* mpInflateInBuf; // as big as the size of a scanline + alphachannel + 1
- sal_uInt8* mpScanPrior; // pointer to the latest scanline
- sal_uInt8* mpTransTab; // for transparency in images with palette colortype
+ std::unique_ptr<sal_uInt8[]>
+ mpInflateInBuf; // as big as the size of a scanline + alphachannel + 1
+ std::unique_ptr<sal_uInt8[]>
+ mpScanPrior; // pointer to the latest scanline
+ std::unique_ptr<sal_uInt8[]>
+ mpTransTab; // for transparency in images with palette colortype
sal_uInt8* mpScanCurrent; // pointer into the current scanline
sal_uInt8* mpColorTable;
std::size_t mnStreamSize; // estimate of PNG file size
@@ -134,8 +137,10 @@ private:
sal_Int32 mnAllocSizeScanlineAlpha;
#endif
// the temporary Scanline (and alpha) for direct scanline copy to Bitmap
- sal_uInt8* mpScanline;
- sal_uInt8* mpScanlineAlpha;
+ std::unique_ptr<sal_uInt8[]>
+ mpScanline;
+ std::unique_ptr<sal_uInt8[]>
+ mpScanlineAlpha;
bool ReadNextChunk();
void ReadRemainingChunks();
@@ -247,13 +252,6 @@ PNGReaderImpl::~PNGReaderImpl()
if( mpColorTable != mpDefaultColorTable )
delete[] mpColorTable;
-
- delete[] mpTransTab;
- delete[] mpInflateInBuf;
- delete[] mpScanPrior;
-
- delete[] mpScanline;
- delete[] mpScanlineAlpha;
}
bool PNGReaderImpl::ReadNextChunk()
@@ -646,9 +644,9 @@ bool PNGReaderImpl::ImplReadHeader( const Size& rPreviewSizeHint )
}
// TODO: switch between both scanlines instead of copying
- mpInflateInBuf = new (std::nothrow) sal_uInt8[ mnScansize ];
- mpScanCurrent = mpInflateInBuf;
- mpScanPrior = new (std::nothrow) sal_uInt8[ mnScansize ];
+ mpInflateInBuf.reset( new (std::nothrow) sal_uInt8[ mnScansize ] );
+ mpScanCurrent = mpInflateInBuf.get();
+ mpScanPrior.reset( new (std::nothrow) sal_uInt8[ mnScansize ] );
if ( !mpInflateInBuf || !mpScanPrior )
return false;
@@ -730,8 +728,8 @@ bool PNGReaderImpl::ImplReadTransparent()
{
if ( mnChunkLen == 2 )
{
- mpTransTab = new sal_uInt8[ 256 ];
- memset( mpTransTab, 0xff, 256);
+ mpTransTab.reset( new sal_uInt8[ 256 ] );
+ memset( mpTransTab.get(), 0xff, 256);
// color type 0 and 4 is always greyscale,
// so the return value can be used as index
sal_uInt8 nIndex = ImplScaleColor();
@@ -758,11 +756,11 @@ bool PNGReaderImpl::ImplReadTransparent()
if ( mnChunkLen <= 256 )
{
mbTransparent = true;
- mpTransTab = new sal_uInt8 [ 256 ];
- memset( mpTransTab, 0xff, 256 );
+ mpTransTab.reset( new sal_uInt8 [ 256 ] );
+ memset( mpTransTab.get(), 0xff, 256 );
if (mnChunkLen > 0)
{
- memcpy( mpTransTab, &(*maDataIter), mnChunkLen );
+ memcpy( mpTransTab.get(), &(*maDataIter), mnChunkLen );
maDataIter += mnChunkLen;
// need alpha transparency if not on/off masking
for( int i = 0; i < mnChunkLen; ++i )
@@ -903,7 +901,7 @@ void PNGReaderImpl::ImplReadIDAT()
while ( ( mpZCodec.GetBreak() ) )
{
// get bytes needed to fill the current scanline
- sal_Int32 nToRead = mnScansize - (mpScanCurrent - mpInflateInBuf);
+ sal_Int32 nToRead = mnScansize - (mpScanCurrent - mpInflateInBuf.get());
sal_Int32 nRead = mpZCodec.ReadAsynchron( aIStrm, mpScanCurrent, nToRead );
if ( nRead < 0 )
{
@@ -917,7 +915,7 @@ void PNGReaderImpl::ImplReadIDAT()
}
else // this scanline is Finished
{
- mpScanCurrent = mpInflateInBuf;
+ mpScanCurrent = mpInflateInBuf.get();
ImplApplyFilter();
ImplDrawScanline( mnXStart, mnXAdd );
@@ -999,7 +997,7 @@ bool PNGReaderImpl::ImplPreparePass()
mnScansize = ( mnScansize*mnPngDepth + 7 ) >> 3;
++mnScansize; // scan size also needs room for the filtertype byte
- memset( mpScanPrior, 0, mnScansize );
+ memset( mpScanPrior.get(), 0, mnScansize );
return true;
}
@@ -1010,9 +1008,9 @@ bool PNGReaderImpl::ImplPreparePass()
void PNGReaderImpl::ImplApplyFilter()
{
OSL_ASSERT( mnScansize >= mnBPP + 1 );
- const sal_uInt8* const pScanEnd = mpInflateInBuf + mnScansize;
+ const sal_uInt8* const pScanEnd = mpInflateInBuf.get() + mnScansize;
- sal_uInt8 nFilterType = *mpInflateInBuf; // the filter type may change each scanline
+ sal_uInt8 nFilterType = mpInflateInBuf[0]; // the filter type may change each scanline
switch ( nFilterType )
{
default: // unknown Scanline Filter Type
@@ -1022,7 +1020,7 @@ void PNGReaderImpl::ImplApplyFilter()
case 1: // Scanline Filter Type "Sub"
{
- sal_uInt8* p1 = mpInflateInBuf + 1;
+ sal_uInt8* p1 = mpInflateInBuf.get() + 1;
const sal_uInt8* p2 = p1;
p1 += mnBPP;
@@ -1037,8 +1035,8 @@ void PNGReaderImpl::ImplApplyFilter()
case 2: // Scanline Filter Type "Up"
{
- sal_uInt8* p1 = mpInflateInBuf + 1;
- const sal_uInt8* p2 = mpScanPrior + 1;
+ sal_uInt8* p1 = mpInflateInBuf.get() + 1;
+ const sal_uInt8* p2 = mpScanPrior.get() + 1;
// use pixels from prior line
while( p1 < pScanEnd )
@@ -1051,8 +1049,8 @@ void PNGReaderImpl::ImplApplyFilter()
case 3: // Scanline Filter Type "Average"
{
- sal_uInt8* p1 = mpInflateInBuf + 1;
- const sal_uInt8* p2 = mpScanPrior + 1;
+ sal_uInt8* p1 = mpInflateInBuf.get() + 1;
+ const sal_uInt8* p2 = mpScanPrior.get() + 1;
const sal_uInt8* p3 = p1;
// use one pixel from prior line
@@ -1070,8 +1068,8 @@ void PNGReaderImpl::ImplApplyFilter()
case 4: // Scanline Filter Type "PaethPredictor"
{
- sal_uInt8* p1 = mpInflateInBuf + 1;
- const sal_uInt8* p2 = mpScanPrior + 1;
+ sal_uInt8* p1 = mpInflateInBuf.get() + 1;
+ const sal_uInt8* p2 = mpScanPrior.get() + 1;
const sal_uInt8* p3 = p1;
const sal_uInt8* p4 = p2;
@@ -1112,7 +1110,7 @@ void PNGReaderImpl::ImplApplyFilter()
break;
}
- memcpy( mpScanPrior, mpInflateInBuf, mnScansize );
+ memcpy( mpScanPrior.get(), mpInflateInBuf.get(), mnScansize );
}
namespace
@@ -1161,7 +1159,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
// => TODO; also do this for nX here instead of in the ImplSet*Pixel() methods
const sal_uInt32 nY = mnYpos >> mnPreviewShift;
- sal_uInt8* pTmp = mpInflateInBuf + 1;
+ sal_uInt8* pTmp = mpInflateInBuf.get() + 1;
if ( mxAcc->HasPalette() ) // alphachannel is not allowed by pictures including palette entries
{
switch ( mxAcc->GetBitCount() )
@@ -1376,7 +1374,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
#if OSL_DEBUG_LEVEL > 0
mnAllocSizeScanline = maOrigSize.Width() * 3;
#endif
- mpScanline = new sal_uInt8[maOrigSize.Width() * 3];
+ mpScanline.reset( new sal_uInt8[maOrigSize.Width() * 3] );
}
if(!mpScanlineAlpha)
@@ -1384,7 +1382,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
#if OSL_DEBUG_LEVEL > 0
mnAllocSizeScanlineAlpha = maOrigSize.Width();
#endif
- mpScanlineAlpha = new sal_uInt8[maOrigSize.Width()];
+ mpScanlineAlpha.reset( new sal_uInt8[maOrigSize.Width()] );
}
}
@@ -1396,8 +1394,8 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
OSL_ENSURE(mnAllocSizeScanline >= maOrigSize.Width() * 3, "Allocated Scanline too small (!)");
OSL_ENSURE(mnAllocSizeScanlineAlpha >= maOrigSize.Width(), "Allocated ScanlineAlpha too small (!)");
#endif
- sal_uInt8* pScanline(mpScanline);
- sal_uInt8* pScanlineAlpha(mpScanlineAlpha);
+ sal_uInt8* pScanline(mpScanline.get());
+ sal_uInt8* pScanlineAlpha(mpScanlineAlpha.get());
for (long nX(0); nX < maOrigSize.Width(); nX++, pTmp += 4)
{
@@ -1421,8 +1419,8 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
// copy scanlines directly to bitmaps for content and alpha; use the formats which
// are able to copy directly to BitmapBuffer
- mxAcc->CopyScanline(nY, mpScanline, ScanlineFormat::N24BitTcBgr, maOrigSize.Width() * 3);
- mpMaskAcc->CopyScanline(nY, mpScanlineAlpha, ScanlineFormat::N8BitPal, maOrigSize.Width());
+ mxAcc->CopyScanline(nY, mpScanline.get(), ScanlineFormat::N24BitTcBgr, maOrigSize.Width() * 3);
+ mpMaskAcc->CopyScanline(nY, mpScanlineAlpha.get(), ScanlineFormat::N8BitPal, maOrigSize.Width());
}
else
{
@@ -1521,7 +1519,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
#if OSL_DEBUG_LEVEL > 0
mnAllocSizeScanline = maOrigSize.Width() * 3;
#endif
- mpScanline = new sal_uInt8[maOrigSize.Width() * 3];
+ mpScanline.reset( new sal_uInt8[maOrigSize.Width() * 3] );
}
if ( mnPngDepth == 8 ) // maybe the source has 16 bit per sample
@@ -1532,7 +1530,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
#if OSL_DEBUG_LEVEL > 0
OSL_ENSURE(mnAllocSizeScanline >= maOrigSize.Width() * 3, "Allocated Scanline too small (!)");
#endif
- sal_uInt8* pScanline(mpScanline);
+ sal_uInt8* pScanline(mpScanline.get());
for (long nX(0); nX < maOrigSize.Width(); nX++, pTmp += 3)
{
@@ -1553,7 +1551,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
// copy scanline directly to bitmap for content; use the format which is able to
// copy directly to BitmapBuffer
- mxAcc->CopyScanline(nY, mpScanline, ScanlineFormat::N24BitTcBgr, maOrigSize.Width() * 3);
+ mxAcc->CopyScanline(nY, mpScanline.get(), ScanlineFormat::N24BitTcBgr, maOrigSize.Width() * 3);
}
else
{
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 30bcf52f1cae..d0b95ceaa5dd 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -43,37 +43,20 @@
ImplMultiTextLineInfo::ImplMultiTextLineInfo()
{
- mpLines = new ImplTextLineInfo*[MULTITEXTLINEINFO_RESIZE];
- mnLines = 0;
- mnSize = MULTITEXTLINEINFO_RESIZE;
}
ImplMultiTextLineInfo::~ImplMultiTextLineInfo()
{
- for( sal_Int32 i = 0; i < mnLines; i++ )
- delete mpLines[i];
- delete [] mpLines;
}
void ImplMultiTextLineInfo::AddLine( ImplTextLineInfo* pLine )
{
- if ( mnSize == mnLines )
- {
- mnSize += MULTITEXTLINEINFO_RESIZE;
- ImplTextLineInfo** pNewLines = new ImplTextLineInfo*[mnSize];
- memcpy( pNewLines, mpLines, mnLines*sizeof(ImplTextLineInfo*) );
- mpLines = pNewLines;
- }
-
- mpLines[mnLines] = pLine;
- mnLines++;
+ mvLines.push_back(std::unique_ptr<ImplTextLineInfo>(pLine));
}
void ImplMultiTextLineInfo::Clear()
{
- for( sal_Int32 i = 0; i < mnLines; i++ )
- delete mpLines[i];
- mnLines = 0;
+ mvLines.clear();
}
void OutputDevice::ImplInitTextColor()
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 8a0bd170612d..bdffc00fbcf5 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -1049,7 +1049,6 @@ class PolyArgs
{
public:
PolyArgs( tools::PolyPolygon& rPolyPoly, sal_uInt16 nMaxPoints );
- ~PolyArgs();
void AddPoint( long nX, long nY, PolyFlags);
void ClosePolygon();
@@ -1060,8 +1059,10 @@ public:
private:
tools::PolyPolygon& mrPolyPoly;
- Point* mpPointAry;
- PolyFlags* mpFlagAry;
+ std::unique_ptr<Point[]>
+ mpPointAry;
+ std::unique_ptr<PolyFlags[]>
+ mpFlagAry;
FT_Vector maPosition;
sal_uInt16 mnMaxPoints;
@@ -1080,17 +1081,11 @@ PolyArgs::PolyArgs( tools::PolyPolygon& rPolyPoly, sal_uInt16 nMaxPoints )
mnPoly(0),
bHasOffline(false)
{
- mpPointAry = new Point[ mnMaxPoints ];
- mpFlagAry = new PolyFlags [ mnMaxPoints ];
+ mpPointAry.reset( new Point[ mnMaxPoints ] );
+ mpFlagAry.reset( new PolyFlags [ mnMaxPoints ] );
maPosition.x = maPosition.y = 0;
}
-PolyArgs::~PolyArgs()
-{
- delete[] mpFlagAry;
- delete[] mpPointAry;
-}
-
void PolyArgs::AddPoint( long nX, long nY, PolyFlags aFlag )
{
SAL_WARN_IF( (mnPoints >= mnMaxPoints), "vcl", "FTGlyphOutline: AddPoint overflow!" );
@@ -1117,7 +1112,7 @@ void PolyArgs::ClosePolygon()
SAL_WARN_IF( (mpFlagAry[0]!=PolyFlags::Normal), "vcl", "FTGlyphOutline: PolyFinishFE failed!" );
SAL_WARN_IF( (mpFlagAry[mnPoints]!=PolyFlags::Normal), "vcl", "FTGlyphOutline: PolyFinishFS failed!" );
- tools::Polygon aPoly( mnPoints, mpPointAry, (bHasOffline ? mpFlagAry : nullptr) );
+ tools::Polygon aPoly( mnPoints, mpPointAry.get(), (bHasOffline ? mpFlagAry.get() : nullptr) );
// #i35928#
// This may be a invalid polygons, e.g. the last point is a control point.
diff --git a/vcl/unx/generic/print/bitmap_gfx.cxx b/vcl/unx/generic/print/bitmap_gfx.cxx
index e28064d6f543..1e0148cbb1d6 100644
--- a/vcl/unx/generic/print/bitmap_gfx.cxx
+++ b/vcl/unx/generic/print/bitmap_gfx.cxx
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <array>
+#include <memory>
#include "psputil.hxx"
#include "unx/printergfx.hxx"
@@ -272,7 +274,8 @@ private:
sal_uInt16 mnValue; // pixelvalue
};
- LZWCTreeNode* mpTable; // LZW compression data
+ std::array<LZWCTreeNode, 4096>
+ mpTable; // LZW compression data
LZWCTreeNode* mpPrefix; // the compression is as same as the TIFF compression
sal_uInt16 mnDataSize;
sal_uInt16 mnClearCode;
@@ -305,8 +308,6 @@ LZWEncoder::LZWEncoder(osl::File* pOutputFile) :
mnOffset = 32; // free bits in dwShift
mdwShift = 0;
- mpTable = new LZWCTreeNode[ 4096 ];
-
for (sal_uInt32 i = 0; i < 4096; i++)
{
mpTable[i].mpBrother = nullptr;
@@ -326,8 +327,6 @@ LZWEncoder::~LZWEncoder()
WriteBits (mpPrefix->mnCode, mnCodeSize);
WriteBits (mnEOICode, mnCodeSize);
-
- delete[] mpTable;
}
void
@@ -354,7 +353,7 @@ LZWEncoder::EncodeByte (sal_uInt8 nByte )
if (!mpPrefix)
{
- mpPrefix = mpTable + nByte;
+ mpPrefix = mpTable.data() + nByte;
}
else
{
@@ -388,14 +387,14 @@ LZWEncoder::EncodeByte (sal_uInt8 nByte )
if(mnTableSize == (sal_uInt16)((1 << mnCodeSize) - 1))
mnCodeSize++;
- p = mpTable + (mnTableSize++);
+ p = mpTable.data() + (mnTableSize++);
p->mpBrother = mpPrefix->mpFirstChild;
mpPrefix->mpFirstChild = p;
p->mnValue = nV;
p->mpFirstChild = nullptr;
}
- mpPrefix = mpTable + nV;
+ mpPrefix = mpTable.data() + nV;
}
}
}