1
0
Fork 0

Codechange: use std::unique_ptr over MallocT/free for dedicated video memory

pull/13320/head
Rubidium 2025-01-14 20:39:35 +01:00 committed by rubidium42
parent 84e049e23c
commit e2b0ea1509
1 changed files with 4 additions and 4 deletions

View File

@ -93,7 +93,7 @@ static void CloseWindowsConsoleThread()
#include "../safeguards.h"
static void *_dedicated_video_mem;
static std::unique_ptr<uint8_t[]> _dedicated_video_mem;
/* Whether a fork has been done. */
bool _dedicated_forks;
@ -108,11 +108,11 @@ std::optional<std::string_view> VideoDriver_Dedicated::Start(const StringList &)
this->UpdateAutoResolution();
int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
_dedicated_video_mem = (bpp == 0) ? nullptr : MallocT<uint8_t>(static_cast<size_t>(_cur_resolution.width) * _cur_resolution.height * (bpp / 8));
if (bpp != 0) _dedicated_video_mem = std::make_unique<uint8_t[]>(static_cast<size_t>(_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) {}