diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index c620f44110..0c3144d003 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -93,7 +93,7 @@ static void CloseWindowsConsoleThread() #include "../safeguards.h" -static void *_dedicated_video_mem; +static std::unique_ptr _dedicated_video_mem; /* Whether a fork has been done. */ bool _dedicated_forks; @@ -108,11 +108,11 @@ std::optional VideoDriver_Dedicated::Start(const StringList &) this->UpdateAutoResolution(); int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth(); - _dedicated_video_mem = (bpp == 0) ? nullptr : MallocT(static_cast(_cur_resolution.width) * _cur_resolution.height * (bpp / 8)); + if (bpp != 0) _dedicated_video_mem = std::make_unique(static_cast(_cur_resolution.width) * _cur_resolution.height * (bpp / 8)); _screen.width = _screen.pitch = _cur_resolution.width; _screen.height = _cur_resolution.height; - _screen.dst_ptr = _dedicated_video_mem; + _screen.dst_ptr = _dedicated_video_mem.get(); ScreenSizeChanged(); BlitterFactory::GetCurrentBlitter()->PostResize(); @@ -139,7 +139,7 @@ void VideoDriver_Dedicated::Stop() #ifdef _WIN32 CloseWindowsConsoleThread(); #endif - free(_dedicated_video_mem); + _dedicated_video_mem = nullptr; } void VideoDriver_Dedicated::MakeDirty(int, int, int, int) {}