fix display server memory leaks

This commit is contained in:
Brad Parker 2018-01-25 21:48:08 -05:00
parent 2dfe14ce4d
commit e2691c425c
5 changed files with 18 additions and 6 deletions

View File

@ -23,9 +23,9 @@ static void* null_display_server_init(void)
return NULL;
}
static void null_display_server_destroy(void)
static void null_display_server_destroy(void *data)
{
(void)data;
}
static bool null_set_window_opacity(void *data, unsigned opacity)

View File

@ -93,8 +93,10 @@ static void* win32_display_server_init(void)
return dispserv;
}
static void win32_display_server_destroy(void)
static void win32_display_server_destroy(void *data)
{
dispserv_win32_t *dispserv = (dispserv_win32_t*)data;
#ifdef HAS_TASKBAR_EXT
if (g_taskbarList && win32_taskbar_is_created())
{
@ -102,6 +104,9 @@ static void win32_display_server_destroy(void)
g_taskbarList = NULL;
}
#endif
if (dispserv)
free(dispserv);
}
static bool win32_set_window_opacity(void *data, unsigned opacity)

View File

@ -34,9 +34,12 @@ static void* x11_display_server_init(void)
return dispserv;
}
static void x11_display_server_destroy(void)
static void x11_display_server_destroy(void *data)
{
dispserv_x11_t *dispserv = (dispserv_x11_t*)data;
if (dispserv)
free(dispserv);
}
static bool x11_set_window_opacity(void *data, unsigned opacity)

View File

@ -27,6 +27,8 @@ void* video_display_server_init(void)
{
enum rarch_display_type type = video_driver_display_type_get();
video_display_server_destroy();
switch (type)
{
case RARCH_DISPLAY_WIN32:
@ -54,7 +56,9 @@ void* video_display_server_init(void)
void video_display_server_destroy(void)
{
if (current_display_server && current_display_server->destroy)
if (current_display_server_data)
current_display_server->destroy(current_display_server_data);
}
bool video_display_server_set_window_opacity(unsigned opacity)

View File

@ -26,7 +26,7 @@ RETRO_BEGIN_DECLS
typedef struct video_display_server
{
void *(*init)(void);
void (*destroy)(void);
void (*destroy)(void *data);
bool (*set_window_opacity)(void *data, unsigned opacity);
bool (*set_window_progress)(void *data, int progress, bool finished);
const char *ident;