diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-04-26 17:32:35 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-04-26 17:32:35 +0200 |
commit | 36a9091ee88ecc0a03235ee144e6babf2f8ef92a (patch) | |
tree | a1e3ab6cf89ab6dcfe027565031878f924f107b6 /desktop | |
parent | 6d7b8977f100e87ed452eaf87da99da052808687 (diff) |
loplugin:useuniqueptr (clang-cl)
Change-Id: I08c2c3557b4cb1804446d5a65e8e0499b27a3329
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/deployment/misc/lockfile.cxx | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/desktop/source/deployment/misc/lockfile.cxx b/desktop/source/deployment/misc/lockfile.cxx index fa30bf256fee..47aa5fb72d2c 100644 --- a/desktop/source/deployment/misc/lockfile.cxx +++ b/desktop/source/deployment/misc/lockfile.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <memory> + #include <stdlib.h> #include <time.h> #ifndef _WIN32 @@ -47,12 +51,11 @@ static OString impl_getHostname() hostname by using the netbios name */ DWORD sz = MAX_COMPUTERNAME_LENGTH + 1; - char* szHost = new char[sz]; - if (GetComputerName(szHost, &sz)) - aHost = OString(szHost); + auto szHost = std::unique_ptr<char[]>(new char[sz]); + if (GetComputerName(szHost.get(), &sz)) + aHost = OString(szHost.get()); else aHost = OString("UNKNOWN"); - delete[] szHost; #else /* Don't do dns lookup on Linux either */ sal_Char pHostName[1024]; |