Use "make_unique" instead of manually allocating and then creating a unique pointer (#1899)

This commit is contained in:
Rose 2022-09-23 12:04:28 -04:00 committed by GitHub
commit d9ef114dbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,7 +16,7 @@ namespace CalculatorApp::ViewModel
{
std::wstring returnString = L"";
const UINT32 length = 1024;
std::unique_ptr<wchar_t[]> spBuffer = std::unique_ptr<wchar_t[]>(new wchar_t[length]);
std::unique_ptr<wchar_t[]> spBuffer = std::make_unique<wchar_t[]>(length);
va_list args = NULL;
va_start(args, pMessage);
DWORD fmtReturnVal = FormatMessage(FORMAT_MESSAGE_FROM_STRING, pMessage->Data(), 0, 0, spBuffer.get(), length, &args);