diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-10 09:48:28 +0200 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-12-18 01:07:46 -0500 |
commit | 0c06cab09ec66cd8720d53ed7abde828d931142b (patch) | |
tree | 3cc4fd40c6db6852017c20eb3fbe00e3523f9edd /vcl/headless | |
parent | e9f5dd68136329250544a4af123148136521a54d (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)
Diffstat (limited to 'vcl/headless')
-rw-r--r-- | vcl/headless/svpgdi.cxx | 21 |
1 files changed, 10 insertions, 11 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; |