[Libreoffice-commits] core.git: fpicker/source

Stephan Bergmann sbergman at redhat.com
Wed Apr 26 15:33:27 UTC 2017


 fpicker/source/win32/filepicker/FilterContainer.cxx |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 3995bf74a6ad711d6f7b63cbe8eeca83d5b0355f
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Apr 26 17:32:57 2017 +0200

    loplugin:useuniqueptr (clang-cl)
    
    Change-Id: I5ed7a980da0d8f6d320db306fcfca969ae700c4f

diff --git a/fpicker/source/win32/filepicker/FilterContainer.cxx b/fpicker/source/win32/filepicker/FilterContainer.cxx
index f428e45e390b..0601affcf320 100644
--- a/fpicker/source/win32/filepicker/FilterContainer.cxx
+++ b/fpicker/source/win32/filepicker/FilterContainer.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <memory>
 #include <stdexcept>
 #include <osl/diagnose.h>
 #include "FilterContainer.hxx"
@@ -238,10 +241,10 @@ OUString SAL_CALL makeWinFilterBuffer( CFilterContainer& aFilterContainer )
     if ( !reqBuffSize )
         return OUString( );
 
-    sal_Unicode* pBuff = new sal_Unicode[reqBuffSize];
+    auto pBuff = std::unique_ptr<sal_Unicode[]>(new sal_Unicode[reqBuffSize]);
 
     // initialize the buffer with 0
-    ZeroMemory( pBuff, sizeof( sal_Unicode ) * reqBuffSize );
+    ZeroMemory( pBuff.get(), sizeof( sal_Unicode ) * reqBuffSize );
 
     OUString winFilterBuff;
     CFilterContainer::FILTER_ENTRY_T nextFilter;
@@ -252,24 +255,21 @@ OUString SAL_CALL makeWinFilterBuffer( CFilterContainer& aFilterContainer )
     while( aFilterContainer.getNextFilter( nextFilter ) )
     {
         wcsmemcpy(
-            pBuff + memPos,
+            pBuff.get() + memPos,
             nextFilter.first.getStr( ),
             nextFilter.first.getLength( ) );
 
         memPos += nextFilter.first.getLength( ) + 1;
 
         wcsmemcpy(
-            pBuff + memPos,
+            pBuff.get() + memPos,
             nextFilter.second.getStr( ),
             nextFilter.second.getLength( ) );
 
         memPos += nextFilter.second.getLength( ) + 1 ;
     }
 
-    winFilterBuff = OUString( pBuff, reqBuffSize );
-
-    // remove the allocated buffer
-    delete [] pBuff;
+    winFilterBuff = OUString( pBuff.get(), reqBuffSize );
 
     return winFilterBuff;
 }


More information about the Libreoffice-commits mailing list