summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-02-08 08:41:00 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-02-08 08:41:00 +0100
commitc0d7a40be2444df158c34fb8aca6a9ff28d9138a (patch)
treed3d3cbb03a4a612a88a949800039eee3a770b6c6 /fpicker
parentfed3783e77e00635e50622e7229b06c9e25451f1 (diff)
loplugin:useuniqueptr (clang-cl)
Change-Id: Ic774c9ad174ea522da85585cd1d36f89ca6b1d64
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/win32/filepicker/getfilenamewrapper.cxx15
1 files changed, 8 insertions, 7 deletions
diff --git a/fpicker/source/win32/filepicker/getfilenamewrapper.cxx b/fpicker/source/win32/filepicker/getfilenamewrapper.cxx
index 16b648da24c4..a7a5a3d764e6 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 );