auto keyword removed where not necessary

This commit is contained in:
Simon Rozman 2016-10-03 14:14:59 +02:00
parent 3b4448dcf4
commit 7b0b38aab3
7 changed files with 36 additions and 36 deletions

View File

@ -360,7 +360,7 @@ inline int vsprintf(_Out_ std::basic_string<_Elem, _Traits, _Ax> &str, _In_z_ _P
} else {
for (size_t capacity = 2*WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem);; capacity *= 2) {
// Allocate on heap and retry.
auto buf = std::unique_ptr<_Elem[]>(new _Elem[capacity]);
std::unique_ptr<_Elem[]> buf(new _Elem[capacity]);
count = vsnprintf(buf.get(), capacity - 1, format, arg);
if (count >= 0) {
str.assign(buf.get(), count);

View File

@ -168,7 +168,7 @@ inline BOOL CredProtectA(_In_ BOOL fAsSelf, _In_ LPCSTR pszCredentials, _In_ DWO
return TRUE;
} else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
// Allocate on heap and retry.
auto buf = std::unique_ptr<_Elem[]>(new _Elem[dwSize]);
std::unique_ptr<_Elem[]> buf(new _Elem[dwSize]);
if (CredProtectA(fAsSelf, const_cast<LPSTR>(pszCredentials), cchCredentials, buf.get(), &dwSize, ProtectionType)) {
sProtectedCredentials.assign(buf.get(), dwSize - 1);
return TRUE;
@ -192,7 +192,7 @@ inline BOOL CredProtectW(_In_ BOOL fAsSelf, _In_ LPCWSTR pszCredentials, _In_ DW
return TRUE;
} else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
// Allocate on heap and retry.
auto buf = std::unique_ptr<_Elem[]>(new _Elem[dwSize]);
std::unique_ptr<_Elem[]> buf(new _Elem[dwSize]);
if (CredProtectW(fAsSelf, const_cast<LPWSTR>(pszCredentials), cchCredentials, buf.get(), &dwSize, ProtectionType)) {
sProtectedCredentials.assign(buf.get(), dwSize - 1);
return TRUE;
@ -216,7 +216,7 @@ inline BOOL CredUnprotectA(_In_ BOOL fAsSelf, _In_ LPCSTR pszProtectedCredential
return TRUE;
} else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
// Allocate on heap and retry.
auto buf = std::unique_ptr<_Elem[]>(new _Elem[dwSize]);
std::unique_ptr<_Elem[]> buf(new _Elem[dwSize]);
if (CredUnprotectA(fAsSelf, const_cast<LPSTR>(pszProtectedCredentials), cchCredentials, buf.get(), &dwSize)) {
sCredentials.assign(buf.get(), dwSize);
return TRUE;
@ -240,7 +240,7 @@ inline BOOL CredUnprotectW(_In_ BOOL fAsSelf, _In_ LPCWSTR pszProtectedCredentia
return TRUE;
} else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
// Allocate on heap and retry.
auto buf = std::unique_ptr<_Elem[]>(new _Elem[dwSize]);
std::unique_ptr<_Elem[]> buf(new _Elem[dwSize]);
if (CredUnprotectW(fAsSelf, const_cast<LPWSTR>(pszProtectedCredentials), cchCredentials, buf.get(), &dwSize)) {
sCredentials.assign(buf.get(), dwSize);
return TRUE;

View File

@ -151,7 +151,7 @@ inline DWORD CertGetNameStringA(_In_ PCCERT_CONTEXT pCertContext, _In_ DWORD dwT
DWORD dwSize = ::CertGetNameStringA(pCertContext, dwType, dwFlags, pvTypePara, NULL, 0);
// Allocate buffer on heap to format the string data into and read it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[dwSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwSize]);
dwSize = ::CertGetNameStringA(pCertContext, dwType, dwFlags, pvTypePara, szBuffer.get(), dwSize);
sNameString.assign(szBuffer.get(), dwSize - 1);
return dwSize;
@ -165,7 +165,7 @@ inline DWORD CertGetNameStringW(_In_ PCCERT_CONTEXT pCertContext, _In_ DWORD dwT
DWORD dwSize = ::CertGetNameStringW(pCertContext, dwType, dwFlags, pvTypePara, NULL, 0);
// Allocate buffer on heap to format the string data into and read it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[dwSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwSize]);
dwSize = ::CertGetNameStringW(pCertContext, dwType, dwFlags, pvTypePara, szBuffer.get(), dwSize);
sNameString.assign(szBuffer.get(), dwSize - 1);
return dwSize;

View File

@ -130,7 +130,7 @@ inline UINT MsiGetPropertyA(_In_ MSIHANDLE hInstall, _In_ LPCSTR szName, _Out_ s
return ERROR_SUCCESS;
} else if (uiResult == ERROR_MORE_DATA) {
// Allocate buffer on heap to read the string data into and read it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[++dwSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]);
uiResult = ::MsiGetPropertyA(hInstall, szName, szBuffer.get(), &dwSize);
sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
return uiResult;
@ -158,7 +158,7 @@ inline UINT MsiGetPropertyW(_In_ MSIHANDLE hInstall, _In_ LPCWSTR szName, _Out_
return ERROR_SUCCESS;
} else if (uiResult == ERROR_MORE_DATA) {
// Allocate buffer on heap to read the string data into and read it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[++dwSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]);
uiResult = ::MsiGetPropertyW(hInstall, szName, szBuffer.get(), &dwSize);
sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
return uiResult;
@ -186,7 +186,7 @@ inline UINT MsiRecordGetStringA(_In_ MSIHANDLE hRecord, _In_ unsigned int iField
return ERROR_SUCCESS;
} else if (uiResult == ERROR_MORE_DATA) {
// Allocate buffer on heap to read the string data into and read it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[++dwSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]);
uiResult = ::MsiRecordGetStringA(hRecord, iField, szBuffer.get(), &dwSize);
sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
return uiResult;
@ -214,7 +214,7 @@ inline UINT MsiRecordGetStringW(_In_ MSIHANDLE hRecord, _In_ unsigned int iField
return ERROR_SUCCESS;
} else if (uiResult == ERROR_MORE_DATA) {
// Allocate buffer on heap to read the string data into and read it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[++dwSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]);
uiResult = ::MsiRecordGetStringW(hRecord, iField, szBuffer.get(), &dwSize);
sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
return uiResult;
@ -242,7 +242,7 @@ inline UINT MsiFormatRecordA(MSIHANDLE hInstall, MSIHANDLE hRecord, std::basic_s
return ERROR_SUCCESS;
} else if (uiResult == ERROR_MORE_DATA) {
// Allocate buffer on heap to format the string data into and read it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[++dwSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]);
uiResult = ::MsiFormatRecordA(hInstall, hRecord, szBuffer.get(), &dwSize);
sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
return uiResult;
@ -270,7 +270,7 @@ inline UINT MsiFormatRecordW(MSIHANDLE hInstall, MSIHANDLE hRecord, std::basic_s
return ERROR_SUCCESS;
} else if (uiResult == ERROR_MORE_DATA) {
// Allocate buffer on heap to format the string data into and read it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[++dwSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]);
uiResult = ::MsiFormatRecordW(hInstall, hRecord, szBuffer.get(), &dwSize);
sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
return uiResult;
@ -318,7 +318,7 @@ inline UINT MsiGetTargetPathA(_In_ MSIHANDLE hInstall, _In_ LPCSTR szFolder, _Ou
return ERROR_SUCCESS;
} else if (uiResult == ERROR_MORE_DATA) {
// Allocate buffer on heap to format the string data into and read it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[++dwSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]);
uiResult = ::MsiGetTargetPathA(hInstall, szFolder, szBuffer.get(), &dwSize);
sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
return uiResult;
@ -346,7 +346,7 @@ inline UINT MsiGetTargetPathW(_In_ MSIHANDLE hInstall, _In_ LPCWSTR szFolder, _O
return ERROR_SUCCESS;
} else if (uiResult == ERROR_MORE_DATA) {
// Allocate buffer on heap to format the string data into and read it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[++dwSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]);
uiResult = ::MsiGetTargetPathW(hInstall, szFolder, szBuffer.get(), &dwSize);
sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
return uiResult;
@ -372,7 +372,7 @@ inline INSTALLSTATE MsiGetComponentPathA(_In_ LPCSTR szProduct, _In_ LPCSTR szCo
return state;
} else if (state == INSTALLSTATE_MOREDATA) {
// Allocate buffer on heap to format the string data into and read it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[++dwSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]);
state = ::MsiGetComponentPathA(szProduct, szComponent, szBuffer.get(), &dwSize);
sValue.assign(szBuffer.get(), state >= INSTALLSTATE_BROKEN ? dwSize : 0);
return state;
@ -398,7 +398,7 @@ inline INSTALLSTATE MsiGetComponentPathW(_In_ LPCWSTR szProduct, _In_ LPCWSTR sz
return state;
} else if (state == INSTALLSTATE_MOREDATA) {
// Allocate buffer on heap to format the string data into and read it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[++dwSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]);
state = ::MsiGetComponentPathW(szProduct, szComponent, szBuffer.get(), &dwSize);
sValue.assign(szBuffer.get(), state >= INSTALLSTATE_BROKEN ? dwSize : 0);
return state;

View File

@ -374,7 +374,7 @@ BOOLEAN GetUserNameExA(_In_ EXTENDED_NAME_FORMAT NameFormat, _Out_ std::basic_st
} else {
if (::GetLastError() == ERROR_MORE_DATA) {
// Allocate buffer on heap and retry.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[ulSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[ulSize]);
if (::GetUserNameExA(NameFormat, szBuffer.get(), &ulSize)) {
sName.assign(szBuffer.get(), ulSize);
return TRUE;
@ -403,7 +403,7 @@ BOOLEAN GetUserNameExW(_In_ EXTENDED_NAME_FORMAT NameFormat, _Out_ std::basic_st
} else {
if (::GetLastError() == ERROR_MORE_DATA) {
// Allocate buffer on heap and retry.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[ulSize]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[ulSize]);
if (::GetUserNameExW(NameFormat, szBuffer.get(), &ulSize)) {
sName.assign(szBuffer.get(), ulSize);
return TRUE;

View File

@ -178,7 +178,7 @@ inline DWORD WlanReasonCodeToString(_In_ DWORD dwReasonCode, _Out_ std::basic_st
for (;;) {
// Increment size and allocate buffer.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[dwSize += 1024]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwSize += 1024]);
// Try!
DWORD dwResult = ::pfnWlanReasonCodeToString(dwReasonCode, dwSize, szBuffer.get(), pReserved);

View File

@ -730,7 +730,7 @@ inline DWORD GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_strin
} else {
for (DWORD dwCapacity = 2*WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem);; dwCapacity *= 2) {
// Allocate on heap and retry.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[dwCapacity]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwCapacity]);
dwResult = ::GetModuleFileNameA(hModule, szBuffer.get(), dwCapacity);
if (dwResult < dwCapacity) {
sValue.assign(szBuffer.get(), dwResult);
@ -755,7 +755,7 @@ inline DWORD GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_strin
} else {
for (DWORD dwCapacity = 2*WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem);; dwCapacity *= 2) {
// Allocate on heap and retry.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[dwCapacity]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwCapacity]);
dwResult = ::GetModuleFileNameW(hModule, szBuffer.get(), dwCapacity);
if (dwResult < dwCapacity) {
sValue.assign(szBuffer.get(), dwResult);
@ -783,7 +783,7 @@ inline int GetWindowTextA(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits
sValue.assign(szBuffer, iResult);
} else {
// Allocate buffer on heap and read the string data into it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[++iResult]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[++iResult]);
iResult = ::GetWindowTextA(hWnd, szBuffer.get(), iResult);
sValue.assign(szBuffer.get(), iResult);
}
@ -812,7 +812,7 @@ inline int GetWindowTextW(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits
sValue.assign(szBuffer, iResult);
} else {
// Allocate buffer on heap and read the string data into it.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[++iResult]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[++iResult]);
iResult = ::GetWindowTextW(hWnd, szBuffer.get(), iResult);
sValue.assign(szBuffer.get(), iResult);
}
@ -863,7 +863,7 @@ inline DWORD ExpandEnvironmentStringsW(_In_ LPCSTR lpSrc, std::basic_string<_Ele
for (DWORD dwSizeOut = (DWORD)strlen(lpSrc) + 0x100;;) {
DWORD dwSizeIn = dwSizeOut;
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[dwSizeIn + 2]); // Note: ANSI version requires one extra char.
std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwSizeIn + 2]); // Note: ANSI version requires one extra char.
dwSizeOut = ::ExpandEnvironmentStringsA(lpSrc, szBuffer.get(), dwSizeIn);
if (dwSizeOut == 0) {
// Error.
@ -887,7 +887,7 @@ inline DWORD ExpandEnvironmentStringsW(_In_ LPCWSTR lpSrc, std::basic_string<_El
for (DWORD dwSizeOut = (DWORD)wcslen(lpSrc) + 0x100;;) {
DWORD dwSizeIn = dwSizeOut;
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[dwSizeIn + 1]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwSizeIn + 1]);
dwSizeOut = ::ExpandEnvironmentStringsW(lpSrc, szBuffer.get(), dwSizeIn);
if (dwSizeOut == 0) {
// Error.
@ -957,7 +957,7 @@ inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_
} else if (lResult == ERROR_MORE_DATA) {
if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
// The value is REG_SZ or REG_MULTI_SZ. Read it now.
auto szBuffer = std::unique_ptr<CHAR[]>(new CHAR[dwSize / sizeof(CHAR)]);
std::unique_ptr<CHAR[]> szBuffer(new CHAR[dwSize / sizeof(CHAR)]);
if ((lResult = ::RegQueryValueExA(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
dwSize /= sizeof(CHAR);
sValue.assign(szBuffer.get(), dwSize && szBuffer[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
@ -965,7 +965,7 @@ inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_
sValue.clear();
} else if (dwType == REG_EXPAND_SZ) {
// The value is REG_EXPAND_SZ. Read it and expand environment variables.
auto szBuffer = std::unique_ptr<CHAR[]>(new CHAR[dwSize / sizeof(CHAR)]);
std::unique_ptr<CHAR[]> szBuffer(new CHAR[dwSize / sizeof(CHAR)]);
if ((lResult = ::RegQueryValueExA(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
if (::ExpandEnvironmentStringsA(szBuffer.get(), sValue) == 0)
lResult = ::GetLastError();
@ -1006,7 +1006,7 @@ inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_
} else if (lResult == ERROR_MORE_DATA) {
if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
// The value is REG_SZ or REG_MULTI_SZ. Read it now.
auto szBuffer = std::unique_ptr<WCHAR[]>(new WCHAR[dwSize / sizeof(WCHAR)]);
std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[dwSize / sizeof(WCHAR)]);
if ((lResult = ::RegQueryValueExW(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
dwSize /= sizeof(WCHAR);
sValue.assign(szBuffer.get(), dwSize && szBuffer[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
@ -1014,7 +1014,7 @@ inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_
sValue.clear();
} else if (dwType == REG_EXPAND_SZ) {
// The value is REG_EXPAND_SZ. Read it and expand environment variables.
auto szBuffer = std::unique_ptr<WCHAR[]>(new WCHAR[dwSize / sizeof(WCHAR)]);
std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[dwSize / sizeof(WCHAR)]);
if ((lResult = ::RegQueryValueExW(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
if (::ExpandEnvironmentStringsW(szBuffer.get(), sValue) == 0)
lResult = ::GetLastError();
@ -1102,7 +1102,7 @@ inline LSTATUS RegLoadMUIStringA(_In_ HKEY hKey, _In_opt_ LPCSTR pszValue, _Out_
sOut.assign(szStackBuffer, dwSize);
} else if (lResult == ERROR_MORE_DATA) {
// Allocate buffer on heap and retry.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[dwSize + 1]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwSize + 1]);
sOut.assign(szBuffer.get(), (lResult = RegLoadMUIStringA(hKey, pszValue, szBuffer.get(), dwSize, &dwSize, Flags, pszDirectory)) == ERROR_SUCCESS ? dwSize : 0);
}
@ -1128,7 +1128,7 @@ inline LSTATUS RegLoadMUIStringW(_In_ HKEY hKey, _In_opt_ LPCWSTR pszValue, _Out
sOut.assign(szStackBuffer, dwSize);
} else if (lResult == ERROR_MORE_DATA) {
// Allocate buffer on heap and retry.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[dwSize + 1]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwSize + 1]);
sOut.assign(szBuffer.get(), (lResult = RegLoadMUIStringW(hKey, pszValue, szBuffer.get(), dwSize, &dwSize, Flags, pszDirectory)) == ERROR_SUCCESS ? dwSize : 0);
}
@ -1151,7 +1151,7 @@ inline int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_cou
} else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
// Query the required output size. Allocate buffer. Then convert again.
cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[cch]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[cch]);
cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
sMultiByteStr.assign(szBuffer.get(), cchWideChar != -1 ? strnlen(szBuffer.get(), cch) : cch - 1);
}
@ -1173,7 +1173,7 @@ inline int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_cou
} else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
// Query the required output size. Allocate buffer. Then convert again.
cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, NULL, 0);
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[cch]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[cch]);
cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szBuffer.get(), cch);
sWideCharStr.assign(szBuffer.get(), cbMultiByte != -1 ? wcsnlen(szBuffer.get(), cch) : cch - 1);
}
@ -1249,7 +1249,7 @@ template<class _Elem, class _Traits, class _Ax> inline int GetDateFormatA(_In_ L
int iResult = GetDateFormatA(Locale, dwFlags, lpDate, lpFormat, NULL, 0);
if (iResult) {
// Allocate buffer on heap and retry.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[iResult]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[iResult]);
iResult = GetDateFormatA(Locale, dwFlags, lpDate, lpFormat, szBuffer.get(), iResult);
sDate.assign(szBuffer.get(), iResult ? iResult - 1 : 0);
return iResult;
@ -1264,7 +1264,7 @@ template<class _Elem, class _Traits, class _Ax> inline int GetDateFormatW(_In_ L
int iResult = GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, NULL, 0);
if (iResult) {
// Allocate buffer on heap and retry.
auto szBuffer = std::unique_ptr<_Elem[]>(new _Elem[iResult]);
std::unique_ptr<_Elem[]> szBuffer(new _Elem[iResult]);
iResult = GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, szBuffer.get(), iResult);
sDate.assign(szBuffer.get(), iResult ? iResult - 1 : 0);
return iResult;