From 5595ee701eab0fef0683c93e3c99788ab1b08520 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 2 Feb 2017 15:17:52 +0100 Subject: loplugin:useuniqueptr Change-Id: I3a246a22baaac8195dc1b94c42994de7d80e8336 --- configmgr/source/winreg.cxx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'configmgr') diff --git a/configmgr/source/winreg.cxx b/configmgr/source/winreg.cxx index c2e709b15686..60f99f1a911f 100644 --- a/configmgr/source/winreg.cxx +++ b/configmgr/source/winreg.cxx @@ -9,6 +9,8 @@ */ #include +#include + #ifdef _MSC_VER #pragma warning(push, 1) /* disable warnings within system headers */ #endif @@ -103,8 +105,10 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil else if(nValues) { // No more subkeys, we are at a leaf - wchar_t* pValueName = new wchar_t[nLongestValueNameLen + 1]; - wchar_t* pValue = new wchar_t[nLongestValueLen + 1]; + auto pValueName = std::unique_ptr( + new wchar_t[nLongestValueNameLen + 1]); + auto pValue = std::unique_ptr( + new wchar_t[nLongestValueLen + 1]); bool bFinal = false; OUString aValue; @@ -114,13 +118,13 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil DWORD nValueNameLen = nLongestValueNameLen + 1; DWORD nValueLen = nLongestValueLen + 1; - RegEnumValueW(hCurKey, i, pValueName, &nValueNameLen, nullptr, nullptr, reinterpret_cast(pValue), &nValueLen); + RegEnumValueW(hCurKey, i, pValueName.get(), &nValueNameLen, nullptr, nullptr, reinterpret_cast(pValue.get()), &nValueLen); const wchar_t wsValue[] = L"Value"; const wchar_t wsFinal[] = L"Final"; - if(!wcscmp(pValueName, wsValue)) - aValue = OUString(pValue); - if(!wcscmp(pValueName, wsFinal) && *reinterpret_cast(pValue) == 1) + if(!wcscmp(pValueName.get(), wsValue)) + aValue = OUString(pValue.get()); + if(!wcscmp(pValueName.get(), wsFinal) && *reinterpret_cast(pValue.get()) == 1) bFinal = true; } sal_Int32 aLastSeparator = aKeyName.lastIndexOf('\\'); @@ -177,8 +181,6 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil for(; nCloseNode > 0; nCloseNode--) writeData(aFileHandle, ""); writeData(aFileHandle, "\n"); - delete[] pValueName; - delete[] pValue; } RegCloseKey(hCurKey); } -- cgit