Cleanup
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
40003c4054
commit
ca4e9d069f
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
SPDX-License-Identifier: MIT
|
SPDX-License-Identifier: MIT
|
||||||
Copyright © 1991-2023 Amebis
|
Copyright © 1991-2023 Amebis
|
||||||
Copyright © 2016 GÉANT
|
Copyright © 2016 GÉANT
|
||||||
|
@ -1056,7 +1056,7 @@ namespace winstd
|
|||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Returns the Windows error number
|
/// Returns the error number
|
||||||
///
|
///
|
||||||
error_type number() const
|
error_type number() const
|
||||||
{
|
{
|
||||||
|
@ -31,17 +31,15 @@ static BOOLEAN GetUserNameExA(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std:
|
|||||||
// Copy from stack.
|
// Copy from stack.
|
||||||
sName.assign(szStackBuffer, ulSize);
|
sName.assign(szStackBuffer, ulSize);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
}
|
||||||
if (::GetLastError() == ERROR_MORE_DATA) {
|
if (::GetLastError() == ERROR_MORE_DATA) {
|
||||||
// Allocate buffer on heap and retry.
|
// Allocate buffer on heap and retry.
|
||||||
std::unique_ptr<char[]> szBuffer(new char[ulSize]);
|
std::unique_ptr<char[]> szBuffer(new char[ulSize]);
|
||||||
if (::GetUserNameExA(NameFormat, szBuffer.get(), &ulSize)) {
|
if (::GetUserNameExA(NameFormat, szBuffer.get(), &ulSize)) {
|
||||||
sName.assign(szBuffer.get(), ulSize);
|
sName.assign(szBuffer.get(), ulSize);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,17 +61,15 @@ static BOOLEAN GetUserNameExW(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std:
|
|||||||
// Copy from stack.
|
// Copy from stack.
|
||||||
sName.assign(szStackBuffer, ulSize);
|
sName.assign(szStackBuffer, ulSize);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
}
|
||||||
if (::GetLastError() == ERROR_MORE_DATA) {
|
if (::GetLastError() == ERROR_MORE_DATA) {
|
||||||
// Allocate buffer on heap and retry.
|
// Allocate buffer on heap and retry.
|
||||||
std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[ulSize]);
|
std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[ulSize]);
|
||||||
if (::GetUserNameExW(NameFormat, szBuffer.get(), &ulSize)) {
|
if (::GetUserNameExW(NameFormat, szBuffer.get(), &ulSize)) {
|
||||||
sName.assign(szBuffer.get(), ulSize);
|
sName.assign(szBuffer.get(), ulSize);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user