[Libreoffice-commits] core.git: vcl/inc vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 30 06:31:59 UTC 2018


 vcl/inc/octree.hxx        |    4 ++--
 vcl/source/gdi/octree.cxx |   14 ++++++--------
 2 files changed, 8 insertions(+), 10 deletions(-)

New commits:
commit 6c99bca30449589a2904891939e12e6a474464eb
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 29 15:06:36 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Aug 30 08:31:30 2018 +0200

    loplugin:useuniqueptr in InverseColorMap
    
    Change-Id: I04801a912397ca0081201f52b756c37f83538be5
    Reviewed-on: https://gerrit.libreoffice.org/59776
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/inc/octree.hxx b/vcl/inc/octree.hxx
index 9178ce730381..ae819d858872 100644
--- a/vcl/inc/octree.hxx
+++ b/vcl/inc/octree.hxx
@@ -93,8 +93,8 @@ class VCL_PLUGIN_PUBLIC InverseColorMap
 {
 private:
 
-    sal_uInt8*                  pBuffer;
-    sal_uInt8*                  pMap;
+    std::unique_ptr<sal_uInt8[]> pBuffer;
+    std::unique_ptr<sal_uInt8[]> pMap;
     const sal_uLong             nBits;
 
     SAL_DLLPRIVATE void ImplCreateBuffers( const sal_uLong nMax );
diff --git a/vcl/source/gdi/octree.cxx b/vcl/source/gdi/octree.cxx
index 3397a1fb08f3..21af8416fee9 100644
--- a/vcl/source/gdi/octree.cxx
+++ b/vcl/source/gdi/octree.cxx
@@ -262,8 +262,8 @@ InverseColorMap::InverseColorMap( const BitmapPalette& rPal ) :
         const long cginc = ( xsqr - ( cGreen << nBits ) ) << 1;
         const long cbinc = ( xsqr - ( cBlue << nBits ) ) << 1;
 
-        sal_uLong* cdp = reinterpret_cast<sal_uLong*>(pBuffer);
-        sal_uInt8* crgbp = pMap;
+        sal_uLong* cdp = reinterpret_cast<sal_uLong*>(pBuffer.get());
+        sal_uInt8* crgbp = pMap.get();
 
         for( r = 0, rxx = crinc; r < nColorMax; rdist += rxx, r++, rxx += xsqr2 )
         {
@@ -282,8 +282,6 @@ InverseColorMap::InverseColorMap( const BitmapPalette& rPal ) :
 
 InverseColorMap::~InverseColorMap()
 {
-    std::free( pBuffer );
-    std::free( pMap );
 }
 
 void InverseColorMap::ImplCreateBuffers( const sal_uLong nMax )
@@ -291,11 +289,11 @@ void InverseColorMap::ImplCreateBuffers( const sal_uLong nMax )
     const sal_uLong nCount = nMax * nMax * nMax;
     const sal_uLong nSize = nCount * sizeof( sal_uLong );
 
-    pMap = static_cast<sal_uInt8*>(std::malloc( nCount ));
-    memset( pMap, 0x00, nCount );
+    pMap.reset(new sal_uInt8[ nCount ]);
+    memset( pMap.get(), 0x00, nCount );
 
-    pBuffer = static_cast<sal_uInt8*>(std::malloc( nSize ));
-    memset( pBuffer, 0xff, nSize );
+    pBuffer.reset(new sal_uInt8[ nSize ]);
+    memset( pBuffer.get(), 0xff, nSize );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list