diff --git a/frontend/menu/backend/menu_backend.h b/frontend/menu/backend/menu_backend.h index 0603066b76..845275ef24 100644 --- a/frontend/menu/backend/menu_backend.h +++ b/frontend/menu/backend/menu_backend.h @@ -18,8 +18,6 @@ typedef struct menu_file_list_cbs typedef struct menu_ctx_driver_backend { int (*iterate)(unsigned); - void (*list_insert)(void *, const char *, const char *, unsigned, size_t); - void (*list_delete)(void *, size_t, size_t); const char *ident; } menu_ctx_driver_backend_t; diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 532a41cac4..e2b4809007 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -746,54 +746,8 @@ static int menu_common_iterate(unsigned action) return ret; } -static void menu_common_list_insert(void *data, - const char *path, const char *label, - unsigned type, size_t idx) -{ - file_list_t *list = (file_list_t*)data; - - if (!list) - return; - - list->list[idx].actiondata = (menu_file_list_cbs_t*) - calloc(1, sizeof(menu_file_list_cbs_t)); - - if (!list->list[idx].actiondata) - { - RARCH_ERR("Action data could not be allocated.\n"); - return; - } - - menu_entries_cbs_init(list, path, label, type, idx); -} - -static void menu_common_list_delete(void *data, size_t idx, - size_t list_size) -{ - menu_file_list_cbs_t *cbs = NULL; - file_list_t *list = (file_list_t*)data; - - if (!list) - return; - - cbs = (menu_file_list_cbs_t*)list->list[idx].actiondata; - - if (cbs) - { - cbs->action_start = NULL; - cbs->action_ok = NULL; - cbs->action_toggle = NULL; - cbs->action_deferred_push = NULL; - free(list->list[idx].actiondata); - } - list->list[idx].actiondata = NULL; -} - - menu_ctx_driver_backend_t menu_ctx_backend_common = { menu_common_iterate, - menu_common_list_insert, - menu_common_list_delete, "menu_common", }; diff --git a/frontend/menu/backend/menu_lakka_backend.c b/frontend/menu/backend/menu_lakka_backend.c index 547ddf59b2..d539c023dc 100644 --- a/frontend/menu/backend/menu_lakka_backend.c +++ b/frontend/menu/backend/menu_lakka_backend.c @@ -526,7 +526,5 @@ static int menu_lakka_iterate(unsigned action) menu_ctx_driver_backend_t menu_ctx_backend_lakka = { menu_lakka_iterate, - NULL, - NULL, "menu_lakka", }; diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index f14a302056..f71b110701 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -17,6 +17,7 @@ #include "menu_common.h" #include "menu_input_line_cb.h" #include "menu_entries.h" +#include "menu_entries_cbs.h" #include "menu_list.h" #include "menu_shader.h" #include "../../dynamic.h" @@ -509,3 +510,46 @@ void menu_common_list_clear(void *data) void menu_common_list_set_selection(void *data) { } + +void menu_common_list_insert(void *data, + const char *path, const char *label, + unsigned type, size_t idx) +{ + file_list_t *list = (file_list_t*)data; + + if (!list) + return; + + list->list[idx].actiondata = (menu_file_list_cbs_t*) + calloc(1, sizeof(menu_file_list_cbs_t)); + + if (!list->list[idx].actiondata) + { + RARCH_ERR("Action data could not be allocated.\n"); + return; + } + + menu_entries_cbs_init(list, path, label, type, idx); +} + +void menu_common_list_delete(void *data, size_t idx, + size_t list_size) +{ + menu_file_list_cbs_t *cbs = NULL; + file_list_t *list = (file_list_t*)data; + + if (!list) + return; + + cbs = (menu_file_list_cbs_t*)list->list[idx].actiondata; + + if (cbs) + { + cbs->action_start = NULL; + cbs->action_ok = NULL; + cbs->action_toggle = NULL; + cbs->action_deferred_push = NULL; + free(list->list[idx].actiondata); + } + list->list[idx].actiondata = NULL; +} diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index 3f5acd919f..566500db91 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -161,6 +161,13 @@ void menu_common_list_clear(void *data); void menu_common_list_set_selection(void *data); +void menu_common_list_insert(void *data, + const char *path, const char *label, + unsigned type, size_t idx); + +void menu_common_list_delete(void *data, size_t idx, + size_t list_size); + #ifdef __cplusplus } #endif diff --git a/frontend/menu/menu_list.c b/frontend/menu/menu_list.c index 613c2f81ad..18dc6f37bd 100644 --- a/frontend/menu/menu_list.c +++ b/frontend/menu/menu_list.c @@ -31,8 +31,7 @@ void menu_list_destroy(file_list_t *list) { if (driver.menu_ctx->list_delete) driver.menu_ctx->list_delete(list, i, list->size); - if (driver.menu_ctx->backend->list_delete) - driver.menu_ctx->backend->list_delete(list, i, list->size); + menu_common_list_delete(list, i, list->size); } end: @@ -204,8 +203,7 @@ void menu_list_pop(file_list_t *list, size_t *directory_ptr) if (driver.menu_ctx->list_delete) driver.menu_ctx->list_delete(list, list_size, list_size); - if (driver.menu_ctx->backend->list_delete) - driver.menu_ctx->backend->list_delete(list, list_size, list_size); + menu_common_list_delete(list, list_size, list_size); } end: @@ -250,9 +248,7 @@ void menu_list_push(file_list_t *list, if (driver.menu_ctx->list_insert) driver.menu_ctx->list_insert(list, path, label, list->size - 1); - if (driver.menu_ctx->backend->list_insert) - driver.menu_ctx->backend->list_insert(list, path, - label, type, list->size - 1); + menu_common_list_insert(list, path, label, type, list->size - 1); } void menu_list_push_refresh(file_list_t *list,