diff --git a/src/openrct2/FileClassifier.cpp b/src/openrct2/FileClassifier.cpp index a2c5ca8c47..dbc6893742 100644 --- a/src/openrct2/FileClassifier.cpp +++ b/src/openrct2/FileClassifier.cpp @@ -12,7 +12,6 @@ #include "Diagnostic.h" #include "core/Console.hpp" #include "core/FileStream.h" -#include "core/Memory.hpp" #include "core/Path.hpp" #include "core/String.hpp" #include "park/ParkFile.h" @@ -176,8 +175,7 @@ static bool TryClassifyAsTD4_TD6(IStream* stream, ClassifiedFileInfo* result) if (ValidateTrackChecksum(data.get(), dataLength)) { - std::unique_ptr)> td6data( - Memory::Allocate(0x10000), &Memory::Free); + const auto td6data = std::make_unique_for_overwrite(0x10000); size_t td6len = DecodeTD6(data.get(), td6data.get(), dataLength); if (td6data != nullptr && td6len >= 8) { diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index 558d85aa46..715a665d3a 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -70,10 +70,9 @@ namespace OpenRCT2::Platform } else { - auto wlvalue = new wchar_t[valueSize]; - GetEnvironmentVariableW(wname.c_str(), wlvalue, valueSize); - result = wlvalue; - delete[] wlvalue; + const auto wBuffer = std::make_unique_for_overwrite(valueSize); + GetEnvironmentVariableW(wname.c_str(), wBuffer.get(), valueSize); + result = wBuffer.get(); } return String::toUtf8(result); } @@ -741,10 +740,8 @@ namespace OpenRCT2::Platform SteamPaths GetSteamPaths() { - wchar_t* wSteamPath; HKEY hKey; DWORD type, size; - LRESULT result; if (RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Valve\\Steam", &hKey) != ERROR_SUCCESS) return {}; @@ -757,13 +754,13 @@ namespace OpenRCT2::Platform } std::string outPath = ""; - wSteamPath = reinterpret_cast(malloc(size)); - result = RegQueryValueExW(hKey, L"SteamPath", nullptr, &type, reinterpret_cast(wSteamPath), &size); + const auto wSteamPath = std::make_unique_for_overwrite(size); + const auto result = RegQueryValueExW( + hKey, L"SteamPath", nullptr, &type, reinterpret_cast(wSteamPath.get()), &size); if (result == ERROR_SUCCESS) { - outPath = String::toUtf8(wSteamPath); + outPath = String::toUtf8(wSteamPath.get()); } - free(wSteamPath); RegCloseKey(hKey); SteamPaths ret = {};