Fix memory leaks

This commit is contained in:
Vincent Wei
2021-03-28 19:36:50 +08:00
parent c089adf2b7
commit bf127a3f4d
2 changed files with 25 additions and 4 deletions
+2
View File
@@ -713,6 +713,8 @@ void __mg_update_secondary_dc (PMAINWIN pWin, HDC secondary_dc,
HDC __mg_get_common_rgba8888_dc (void);
BOOL __mg_reset_common_rgba8888_dc (int width, int height, int pitch,
void* pixels);
/* Since 5.0.6 */
void __mg_destroy_common_rgba8888_dc (void);
/* Since 5.0.0.
helpers to update the private client DC of window and it's descendants */
+23 -4
View File
@@ -116,8 +116,15 @@ static pthread_mutex_t dcslot;
BLOCKHEAP __mg_FreeClipRectList;
/************************* static functions declaration **********************/
static void dc_InitClipRgnInfo (void);
static void dc_DeinitClipRgnInfo(void);
static inline void dc_InitClipRgnInfo (void)
{
return;
}
static inline void dc_DeinitClipRgnInfo(void)
{
return;
}
static void dc_InitDC (PDC pdc, HWND hWnd, BOOL bIsClient);
static void dc_InitMemDCFrom (PDC pdc, const PDC pdc_ref);
static void dc_InitScreenDC (PDC pdc, GAL_Surface* surface);
@@ -322,6 +329,9 @@ void mg_TerminateScreenDC (void)
dc_DeinitClipRgnInfo();
/* Since 5.0.6 */
__mg_destroy_common_rgba8888_dc ();
DESTROY_LOCK (&__mg_gdilock);
DESTROY_LOCK (&dcslot);
@@ -522,6 +532,7 @@ Uint32 GUIAPI GetGDCapability (HDC hdc, int iItem)
return iret;
}
#if 0 /* Since 5.0.6: deprecated */
/* This function init clip region in all DC slots. */
static void dc_InitClipRgnInfo(void)
{
@@ -552,7 +563,7 @@ static void dc_DeinitClipRgnInfo(void)
EmptyClipRgn (&DCSlot[i].ecrgn);
}
}
#endif /* Since 5.0.6: deprecated */
static inline void dc_CalculateDevRC4GenDC (PDC pdc);
@@ -4253,9 +4264,9 @@ HDC drmCreateDCFromPrimeFdEx (GHANDLE video, int prime_fd, size_t size,
#endif /* defined _MGGAL_DRM */
/* Since 5.0.0 */
static HDC _dc_common_rgba8888 = HDC_INVALID;
HDC __mg_get_common_rgba8888_dc (void)
{
static HDC _dc_common_rgba8888 = HDC_INVALID;
static char fake_bits [4];
if (_dc_common_rgba8888 == HDC_INVALID) {
@@ -4309,6 +4320,14 @@ BOOL __mg_reset_common_rgba8888_dc (int width, int height, int pitch,
return TRUE;
}
void __mg_destroy_common_rgba8888_dc (void)
{
if (_dc_common_rgba8888 != HDC_INVALID) {
DeleteMemDC (_dc_common_rgba8888);
_dc_common_rgba8888 = HDC_INVALID;
}
}
struct _travel_context;
typedef void (*on_control_fn) (struct _travel_context* ctxt, PCONTROL child);