From 2351701d533c4b489d633b9602930be57caff801 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 23 Apr 2018 14:56:15 +0200 Subject: loplugin:useuniqueptr pass BitmapBuffer around via std::unique_ptr Change-Id: I0a20e7d3816714e42d6863fff27734dd08ae24ae Reviewed-on: https://gerrit.libreoffice.org/53357 Tested-by: Jenkins Reviewed-by: Noel Grandin --- vcl/headless/svpgdi.cxx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'vcl/headless/svpgdi.cxx') diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 7543bc69c760..9a3e9247659c 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -134,7 +134,7 @@ namespace } } - BitmapBuffer* FastConvert24BitRgbTo32BitCairo(const BitmapBuffer* pSrc) + std::unique_ptr FastConvert24BitRgbTo32BitCairo(const BitmapBuffer* pSrc) { if (pSrc == nullptr) return nullptr; @@ -142,7 +142,7 @@ namespace assert(pSrc->mnFormat == SVP_24BIT_FORMAT); const long nWidth = pSrc->mnWidth; const long nHeight = pSrc->mnHeight; - BitmapBuffer* pDst = new BitmapBuffer; + std::unique_ptr pDst(new BitmapBuffer); pDst->mnFormat = (ScanlineFormat::N32BitTcArgb | ScanlineFormat::TopDown); pDst->mnWidth = nWidth; pDst->mnHeight = nHeight; @@ -156,7 +156,6 @@ namespace { SAL_WARN("vcl.gdi", "checked multiply failed"); pDst->mpBits = nullptr; - delete pDst; return nullptr; } @@ -165,7 +164,6 @@ namespace { SAL_WARN("vcl.gdi", "scanline calculation wraparound"); pDst->mpBits = nullptr; - delete pDst; return nullptr; } @@ -177,7 +175,6 @@ namespace { // memory exception, clean up pDst->mpBits = nullptr; - delete pDst; return nullptr; } @@ -242,10 +239,10 @@ namespace const BitmapBuffer* pSrc = rSrcBmp.GetBuffer(); const SalTwoRect aTwoRect = { 0, 0, pSrc->mnWidth, pSrc->mnHeight, 0, 0, pSrc->mnWidth, pSrc->mnHeight }; - BitmapBuffer* pTmp = (pSrc->mnFormat == SVP_24BIT_FORMAT + std::unique_ptr pTmp = (pSrc->mnFormat == SVP_24BIT_FORMAT ? FastConvert24BitRgbTo32BitCairo(pSrc) : StretchAndConvert(*pSrc, aTwoRect, SVP_CAIRO_FORMAT)); - aTmpBmp.Create(pTmp); + aTmpBmp.Create(std::move(pTmp)); assert(aTmpBmp.GetBitCount() == 32); source = SvpSalGraphics::createCairoSurface(aTmpBmp.GetBuffer()); -- cgit