Get rid of menu_entries_get_at_offset

This commit is contained in:
twinaphex 2021-03-10 05:23:50 +01:00
parent bbe46333e1
commit 003fc7ccc8
8 changed files with 39 additions and 47 deletions

View File

@ -414,9 +414,10 @@ static void menu_action_setting_disp_set_label_menu_file_core(
const char *alt = NULL;
strcpy_literal(s, "(CORE)");
menu_entries_get_at_offset(list, i, NULL,
NULL, NULL, NULL, &alt);
file_list_get_at_offset(list, i, NULL, NULL, NULL, NULL);
alt = list->list[i].alt
? list->list[i].alt
: list->list[i].path;
*w = (unsigned)strlen(s);
if (alt)
strlcpy(s2, alt, len2);
@ -438,8 +439,10 @@ static void menu_action_setting_disp_set_label_core_updater_entry(
*s = '\0';
*w = 0;
menu_entries_get_at_offset(list, i, NULL,
NULL, NULL, NULL, &alt);
file_list_get_at_offset(list, i, NULL, NULL, NULL, NULL);
alt = list->list[i].alt
? list->list[i].alt
: list->list[i].path;
if (alt)
strlcpy(s2, alt, len2);
@ -490,8 +493,10 @@ static void menu_action_setting_disp_set_label_core_manager_entry(
*s = '\0';
*w = 0;
menu_entries_get_at_offset(list, i, NULL,
NULL, NULL, NULL, &alt);
file_list_get_at_offset(list, i, NULL, NULL, NULL, NULL);
alt = list->list[i].alt
? list->list[i].alt
: list->list[i].path;
if (alt)
strlcpy(s2, alt, len2);
@ -525,8 +530,10 @@ static void menu_action_setting_disp_set_label_core_lock(
*s = '\0';
*w = 0;
menu_entries_get_at_offset(list, i, NULL,
NULL, NULL, NULL, &alt);
file_list_get_at_offset(list, i, NULL, NULL, NULL, NULL);
alt = list->list[i].alt
? list->list[i].alt
: list->list[i].path;
if (alt)
strlcpy(s2, alt, len2);

View File

@ -1472,8 +1472,10 @@ static int action_bind_sublabel_core_backup_entry(
const char *crc = NULL;
/* crc is entered as 'alt' text */
menu_entries_get_at_offset(list, i, NULL,
NULL, NULL, NULL, &crc);
file_list_get_at_offset(list, i, NULL, NULL, NULL, NULL);
crc = list->list[i].alt
? list->list[i].alt
: list->list[i].path;
/* Set sublabel prefix */
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_BACKUP_CRC), len);

View File

@ -936,8 +936,8 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
/* If the playlist icon doesn't exist return default */
if (!path_is_valid(texturepath))
fill_pathname_join_concat(texturepath, icons_path, "default",
".png", sizeof(texturepath));
fill_pathname_join_concat(texturepath, icons_path, "default",
".png", sizeof(texturepath));
ti.width = 0;
ti.height = 0;
@ -984,9 +984,11 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
}
/* Console name */
menu_entries_get_at_offset(
&ozone->horizontal_list, i,
NULL, NULL, NULL, NULL, &console_name);
file_list_get_at_offset(
&ozone->horizontal_list, i, NULL, NULL, NULL, NULL);
console_name = ozone->horizontal_list.list[i].alt
? ozone->horizontal_list.list[i].alt
: ozone->horizontal_list.list[i].path;
if (node->console_name)
free(node->console_name);
@ -994,8 +996,10 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
/* Note: console_name will *always* be valid here,
* but provide a fallback to prevent NULL pointer
* dereferencing in case of unknown errors... */
node->console_name = strdup(
console_name ? console_name : path);
if (console_name)
node->console_name = strdup(console_name);
else
node->console_name = strdup(path);
}
}
}

View File

@ -1513,10 +1513,10 @@ static void stripes_set_title(stripes_handle_t *stripes)
else
{
const char *path = NULL;
menu_entries_get_at_offset(
file_list_get_at_offset(
&stripes->horizontal_list,
stripes->categories_selection_ptr - (stripes->system_tab_end + 1),
&path, NULL, NULL, NULL, NULL);
&path, NULL, NULL, NULL);
if (!path)
return;

View File

@ -1881,10 +1881,9 @@ static void xmb_set_title(xmb_handle_t *xmb)
{
const char *path = NULL;
menu_entries_get_at_offset(
&xmb->horizontal_list,
file_list_get_at_offset(&xmb->horizontal_list,
xmb->categories_selection_ptr - (xmb->system_tab_end + 1),
&path, NULL, NULL, NULL, NULL);
&path, NULL, NULL, NULL);
if (!path)
return;

View File

@ -3463,9 +3463,7 @@ static unsigned menu_displaylist_parse_cores(
unsigned type = 0;
const char *path = NULL;
menu_entries_get_at_offset(info->list,
i, &path, NULL, &type, NULL,
NULL);
file_list_get_at_offset(info->list, i, &path, NULL, &type, NULL);
if (type == FILE_TYPE_CORE)
{

View File

@ -179,10 +179,6 @@ size_t menu_entries_get_stack_size(size_t idx);
size_t menu_entries_get_size(void);
void menu_entries_get_at_offset(const file_list_t *list, size_t idx,
const char **path, const char **label, unsigned *file_type,
size_t *entry_idx, const char **alt);
void menu_entries_prepend(file_list_t *list,
const char *path, const char *label,
enum msg_hash_enums enum_idx,

View File

@ -1950,8 +1950,7 @@ static int generic_menu_iterate(
const char *path = NULL;
/* Get core path */
menu_entries_get_at_offset(selection_buf, selection,
&path, NULL, NULL, NULL, NULL);
file_list_get_at_offset(selection_buf, selection, &path, NULL, NULL, NULL);
/* Search for specified core */
if (core_list && path &&
@ -1974,8 +1973,7 @@ static int generic_menu_iterate(
core_info_ctx_find_t core_info;
/* Get core path */
menu_entries_get_at_offset(selection_buf, selection,
&path, NULL, NULL, NULL, NULL);
file_list_get_at_offset(selection_buf, selection, &path, NULL, NULL, NULL);
/* Search for specified core */
core_info.inf = NULL;
@ -2030,8 +2028,7 @@ static int generic_menu_iterate(
unsigned type = 0;
enum msg_hash_enums enum_idx = MSG_UNKNOWN;
size_t selection = menu_st->selection_ptr;
menu_entries_get_at_offset(selection_buf, selection,
NULL, NULL, &type, NULL, NULL);
file_list_get_at_offset(selection_buf, selection, NULL, NULL, &type, NULL);
switch (type)
{
@ -2714,17 +2711,6 @@ static void menu_list_flush_stack(
}
}
void menu_entries_get_at_offset(const file_list_t *list, size_t idx,
const char **path, const char **label, unsigned *file_type,
size_t *entry_idx, const char **alt)
{
file_list_get_at_offset(list, idx, path, label, file_type, entry_idx);
if (list && alt)
*alt = list->list[idx].alt
? list->list[idx].alt
: list->list[idx].path;
}
/**
* menu_entries_elem_get_first_char:
* @list : File list handle.