diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-04-26 17:35:17 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-04-26 17:37:13 +0200 |
commit | 10006071c0e39eef7c30e227d619dd2997a4fec7 (patch) | |
tree | 387a972ad6bf7db10c27e9edd3fef0f40c3b0a2b /sal | |
parent | 1a476f14c9b1e23fa761bf09904eb5c8c7e46c47 (diff) |
loplugin:useuniqueptr (clang-cl)
Change-Id: I491fb1fdcc3f5f64e4adb7276217bbdc13a1fa19
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/w32/process.cxx | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx index be617d55adc7..8aa06b468c52 100644 --- a/sal/osl/w32/process.cxx +++ b/sal/osl/w32/process.cxx @@ -29,6 +29,7 @@ #endif #include <cassert> +#include <memory> #include <osl/diagnose.h> #include <osl/security.h> @@ -497,12 +498,12 @@ oslProcessError SAL_CALL osl_setEnvironment(rtl_uString *ustrVar, rtl_uString *u LPCWSTR lpValue = reinterpret_cast<LPCWSTR>(ustrValue->buffer); if (SetEnvironmentVariableW(lpName, lpValue)) { - wchar_t *buffer = new wchar_t[wcslen(lpName) + 1 + wcslen(lpValue) + 1]; - wcscpy(buffer, lpName); - wcscat(buffer, L"="); - wcscat(buffer, lpValue); - _wputenv(buffer); - delete[] buffer; + auto buffer = std::unique_ptr<wchar_t[]>( + new wchar_t[wcslen(lpName) + 1 + wcslen(lpValue) + 1]); + wcscpy(buffer.get(), lpName); + wcscat(buffer.get(), L"="); + wcscat(buffer.get(), lpValue); + _wputenv(buffer.get()); return osl_Process_E_None; } return osl_Process_E_Unknown; @@ -515,11 +516,11 @@ oslProcessError SAL_CALL osl_clearEnvironment(rtl_uString *ustrVar) LPCWSTR lpName = reinterpret_cast<LPCWSTR>(ustrVar->buffer); if (SetEnvironmentVariableW(lpName, nullptr)) { - wchar_t *buffer = new wchar_t[wcslen(lpName) + 1 + 1]; - wcscpy(buffer, lpName); - wcscat(buffer, L"="); - _wputenv(buffer); - delete[] buffer; + auto buffer = std::unique_ptr<wchar_t[]>( + new wchar_t[wcslen(lpName) + 1 + 1]); + wcscpy(buffer.get(), lpName); + wcscat(buffer.get(), L"="); + _wputenv(buffer.get()); return osl_Process_E_None; } return osl_Process_E_Unknown; |