From e2b0ea15097561844b7b29560cd80ae7a9a6e7af Mon Sep 17 00:00:00 2001 From: Rubidium Date: Tue, 14 Jan 2025 20:39:35 +0100 Subject: [PATCH] Codechange: use std::unique_ptr over MallocT/free for dedicated video memory --- src/video/dedicated_v.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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) {}