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

Stephan Bergmann sbergman at redhat.com
Wed Feb 8 07:41:31 UTC 2017


 fpicker/source/win32/filepicker/getfilenamewrapper.cxx |   15 ++++++++-------
 shell/source/win32/shlxthandler/util/utilities.cxx     |   11 +++++++----
 2 files changed, 15 insertions(+), 11 deletions(-)

New commits:
commit 7c6278431483efe76059a6a86889f73233fd034b
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Feb 8 08:41:17 2017 +0100

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

diff --git a/shell/source/win32/shlxthandler/util/utilities.cxx b/shell/source/win32/shlxthandler/util/utilities.cxx
index 78f960b..66686a7 100644
--- a/shell/source/win32/shlxthandler/util/utilities.cxx
+++ b/shell/source/win32/shlxthandler/util/utilities.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <memory>
+
 #include "config.hxx"
 #include "utilities.hxx"
 
@@ -157,11 +161,10 @@ std::wstring getShortPathName( const std::wstring& aLongName )
 
     if ( length != 0 )
     {
-        WCHAR* buffer = new WCHAR[ length+1 ];
-        length = GetShortPathNameW( aLongName.c_str(), buffer, length );
+        auto buffer = std::unique_ptr<WCHAR[]>(new WCHAR[ length+1 ]);
+        length = GetShortPathNameW( aLongName.c_str(), buffer.get(), length );
         if ( length != 0 )
-            shortName = std::wstring( buffer );
-        delete [] buffer;
+            shortName = std::wstring( buffer.get() );
     }
     return shortName;
 }
commit c0d7a40be2444df158c34fb8aca6a9ff28d9138a
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Feb 8 08:41:00 2017 +0100

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

diff --git a/fpicker/source/win32/filepicker/getfilenamewrapper.cxx b/fpicker/source/win32/filepicker/getfilenamewrapper.cxx
index 16b648d..a7a5a3d 100644
--- a/fpicker/source/win32/filepicker/getfilenamewrapper.cxx
+++ b/fpicker/source/win32/filepicker/getfilenamewrapper.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <memory>
 #include <stdio.h>
 #include <osl/diagnose.h>
 #include <osl/thread.h>
@@ -70,19 +73,17 @@ namespace /* private */
                     if ( m_nBufLen - 1 > MAX_PATH )
                     {
                         DWORD nNewLen = m_nBufLen + 8;
-                        wchar_t* pNewBuffer = new wchar_t[nNewLen];
+                        auto pNewBuffer = std::unique_ptr<wchar_t>(new wchar_t[nNewLen]);
                         if ( m_nBufLen > 3 && m_pBuffer[0] == (wchar_t)'\\' && m_pBuffer[1] == (wchar_t)'\\' )
                         {
                             if ( m_pBuffer[2] == (wchar_t)'?' )
-                                _snwprintf( pNewBuffer, nNewLen, L"%s", m_pBuffer );
+                                _snwprintf( pNewBuffer.get(), nNewLen, L"%s", m_pBuffer );
                             else
-                                _snwprintf( pNewBuffer, nNewLen, L"\\\\?\\UNC\\%s", m_pBuffer+2 );
+                                _snwprintf( pNewBuffer.get(), nNewLen, L"\\\\?\\UNC\\%s", m_pBuffer+2 );
                         }
                         else
-                            _snwprintf( pNewBuffer, nNewLen, L"\\\\?\\%s", m_pBuffer );
-                        bDirSet = SetCurrentDirectoryW( pNewBuffer );
-
-                        delete [] pNewBuffer;
+                            _snwprintf( pNewBuffer.get(), nNewLen, L"\\\\?\\%s", m_pBuffer );
+                        bDirSet = SetCurrentDirectoryW( pNewBuffer.get() );
                     }
                     else
                         bDirSet = SetCurrentDirectoryW( m_pBuffer );


More information about the Libreoffice-commits mailing list