Fix memory leak.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2020-07-05 14:42:56 +01:00
parent 0539fd9a69
commit 38908c7d6d
4 changed files with 21 additions and 2 deletions

View file

@ -731,6 +731,13 @@ void VideoInitializeOriginal(baseColors_t pBaseNtscColors)
PalIndex2RGB[HGR_VIOLET] = PalIndex2RGB[MAGENTA];
}
void VideoDestroyOriginal()
{
delete [] g_pSourcePixels;
g_pSourcePixels = NULL;
}
//===========================================================================
static UINT g_rgbFlags = 0;

View file

@ -7,6 +7,8 @@ void UpdateDLoResCell(int x, int y, uint16_t addr, bgra_t *pVideoAddress);
const UINT kNumBaseColors = 16;
typedef bgra_t (*baseColors_t)[kNumBaseColors];
void VideoInitializeOriginal(baseColors_t pBaseNtscColors);
void VideoDestroyOriginal();
void RGB_SetVideoMode(WORD address);
bool RGB_Is140Mode(void);

View file

@ -123,6 +123,7 @@ namespace
HD_Destroy();
PrintDestroy();
MemDestroy();
VideoDestroy();
MB_Destroy();
DSUninit();
CpuDestroy();

View file

@ -74,8 +74,6 @@ int const kVDisplayableScanLines = 192; // max displayable scanlines
static COLORREF customcolors[256]; // MONOCHROME is last custom color
static HBITMAP g_hDeviceBitmap;
static HDC g_hDeviceDC;
static LPBITMAPINFO g_pFramebufferinfo = NULL;
COLORREF g_nMonochromeRGB = RGB(0xC0,0xC0,0xC0);
@ -128,6 +126,17 @@ void VideoInitialize ()
}
void VideoDestroy () {
// DESTROY BUFFERS
VirtualFree(g_pFramebufferinfo,0,MEM_RELEASE);
g_pFramebufferinfo = NULL;
free(g_pFramebufferbits);
g_pFramebufferbits = NULL;
VideoDestroyOriginal();
}
void VideoReinitialize (bool bInitVideoScannerAddress /*= true*/)
{
NTSC_VideoReinitialize( g_dwCyclesThisFrame, bInitVideoScannerAddress );