(menu_driver.c) Pass userdata to free callback

This commit is contained in:
twinaphex 2015-12-11 14:38:57 +01:00
parent fa9f0a32e8
commit 2215aa2c87
6 changed files with 18 additions and 38 deletions

View File

@ -980,8 +980,7 @@ error:
static void mui_free(void *data)
{
menu_handle_t *menu = (menu_handle_t*)data;
mui_handle_t *mui = menu ? (mui_handle_t*)menu->userdata : NULL;
mui_handle_t *mui = (mui_handle_t*)data;
if (!mui)
return;
@ -989,10 +988,6 @@ static void mui_free(void *data)
gfx_coord_array_free(&mui->list_block.carr);
font_driver_bind_block(NULL, NULL);
if (menu->userdata)
free(menu->userdata);
menu->userdata = NULL;
}
static void mui_context_bg_destroy(mui_handle_t *mui)

View File

@ -694,14 +694,6 @@ static void rgui_free(void *data)
{
uint8_t *font_fb;
bool fb_font_inited = false;
menu_handle_t *menu = (menu_handle_t*)data;
if (!menu)
return;
if (menu->userdata)
free(menu->userdata);
menu->userdata = NULL;
menu_display_ctl(MENU_DISPLAY_CTL_FONT_DATA_INIT, &fb_font_inited);
menu_display_ctl(MENU_DISPLAY_CTL_FONT_FB, &font_fb);

View File

@ -295,6 +295,7 @@ static void rmenu_context_destroy(void *data)
static void rmenu_free(void *data)
{
(void)data;
}
static int rmenu_environ(menu_environ_cb_t type, void *data)

View File

@ -1966,16 +1966,10 @@ error:
static void xmb_free(void *data)
{
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = (menu_handle_t*)data;
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (menu && menu->userdata)
if (xmb)
{
xmb = (xmb_handle_t*)menu->userdata;
if (!xmb)
return;
if (xmb->menu_stack_old)
file_list_free(xmb->menu_stack_old);
xmb->menu_stack_old = NULL;
@ -1988,10 +1982,6 @@ static void xmb_free(void *data)
xmb->horizontal_list = NULL;
gfx_coord_array_free(&xmb->raster_block.carr);
if (menu->userdata)
free(menu->userdata);
menu->userdata = NULL;
}
font_driver_bind_block(NULL, NULL);

View File

@ -1102,18 +1102,13 @@ error:
static void zarch_free(void *data)
{
menu_handle_t *menu = (menu_handle_t*)data;
zui_t *zui = (zui_t*)menu->userdata;
if (!zui || !menu)
return;
zui_t *zui = (zui_t*)data;
if (zui)
{
gfx_coord_array_free(&zui->ca);
gfx_coord_array_free(&zui->tmp_block.carr);
if (menu->userdata)
free(menu->userdata);
menu->userdata = NULL;
}
font_driver_bind_block(NULL, NULL);
}

View File

@ -269,7 +269,14 @@ void menu_driver_free(menu_handle_t *menu)
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
if (driver->free)
driver->free(menu);
driver->free(menu_driver_data ? menu_driver_data->userdata : NULL);
if (!menu_driver_data)
return;
if (menu_driver_data->userdata)
free(menu_driver_data->userdata);
menu_driver_data->userdata = NULL;
}
int menu_driver_iterate(enum menu_action action)