file_list_get_size - list can be NULL, in which case return 0

This commit is contained in:
twinaphex 2021-01-21 00:24:32 +01:00
parent 1344ae2ddd
commit a772eb550d
5 changed files with 17 additions and 15 deletions

View File

@ -193,7 +193,7 @@ size_t file_list_get_size(const file_list_t *list)
size_t file_list_get_directory_ptr(const file_list_t *list)
{
size_t size = list->size;
size_t size = list ? list->size : 0;
return list->list[size].directory_ptr;
}

View File

@ -3763,7 +3763,7 @@ size_t ozone_list_get_size(void *data, enum menu_list_type type)
void ozone_free_list_nodes(file_list_t *list, bool actiondata)
{
unsigned i, size = (unsigned)list->size;
unsigned i, size = list ? (unsigned)list->size : 0;
for (i = 0; i < size; ++i)
{

View File

@ -507,7 +507,7 @@ void ozone_draw_entries(
menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i);
entries_end = selection_buf->size;
entries_end = selection_buf ? selection_buf->size : 0;
y = ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->dimensions.entry_padding_vertical;
sidebar_offset = ozone->sidebar_offset;
entry_width = video_width - (unsigned) ozone->dimensions_sidebar_width - ozone->sidebar_offset - entry_padding * 2 - ozone->animations.thumbnail_bar_position;

View File

@ -434,7 +434,7 @@ static void stripes_free_node(stripes_node_t *node)
*/
static void stripes_free_list_nodes(file_list_t *list, bool actiondata)
{
unsigned i, size = list->size;
unsigned i, size = list ? list->size : 0;
for (i = 0; i < size; ++i)
{
@ -1195,7 +1195,7 @@ static void stripes_list_open_old(stripes_handle_t *stripes,
{
unsigned i, height = 0;
int threshold = stripes->icon_size * 10;
size_t end = list->size;
size_t end = list ? list->size : NULL;
video_driver_get_size(NULL, &height);
@ -1255,7 +1255,7 @@ static void stripes_list_open_new(stripes_handle_t *stripes,
unsigned stripes_system_tab = 0;
size_t skip = 0;
int threshold = stripes->icon_size * 10;
size_t end = list->size;
size_t end = list ? list->size : NULL;
video_driver_get_size(NULL, &height);
@ -1399,7 +1399,7 @@ static void stripes_list_switch_old(stripes_handle_t *stripes,
file_list_t *list, int dir, size_t current)
{
unsigned i, first, last, height;
size_t end = list->size;
size_t end = list ? list->size : NULL;
float ix = -stripes->icon_spacing_horizontal * dir;
float ia = 0;
@ -1472,7 +1472,7 @@ static void stripes_list_switch_new(stripes_handle_t *stripes,
}
}
end = list->size;
end = list ? list->size : NULL;
first = 0;
last = end > 0 ? end - 1 : 0;
@ -2554,7 +2554,7 @@ static void stripes_draw_items(
core_node = stripes_get_userdata_from_horizontal_list(
stripes, (unsigned)(cat_selection_ptr - (stripes->system_tab_end + 1)));
end = list->size;
end = list ? list->size : NULL;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0;

View File

@ -679,7 +679,7 @@ static void xmb_free_node(xmb_node_t *node)
*/
static void xmb_free_list_nodes(file_list_t *list, bool actiondata)
{
unsigned i, size = (unsigned)list->size;
unsigned i, size = list ? (unsigned)list->size : 0;
for (i = 0; i < size; ++i)
{
@ -1546,7 +1546,7 @@ static void xmb_list_open_old(xmb_handle_t *xmb,
{
unsigned i, height = 0;
int threshold = xmb->icon_size * 10;
size_t end = list->size;
size_t end = list ? list->size : 0;
video_driver_get_size(NULL, &height);
@ -1605,7 +1605,7 @@ static void xmb_list_open_new(xmb_handle_t *xmb,
unsigned xmb_system_tab = 0;
size_t skip = 0;
int threshold = xmb->icon_size * 10;
size_t end = list->size;
size_t end = list ? list->size : 0;
video_driver_get_size(NULL, &height);
@ -1765,7 +1765,7 @@ static void xmb_list_switch_old(xmb_handle_t *xmb,
file_list_t *list, int dir, size_t current)
{
unsigned i, height;
size_t end = list->size;
size_t end = list ? list->size : 0;
float ix = -xmb->icon_spacing_horizontal * dir;
float ia = 0;
unsigned first = 0;
@ -1838,7 +1838,8 @@ static void xmb_list_switch_new(xmb_handle_t *xmb,
}
}
end = list->size;
end = list ? list->size : 0;
first = 0;
last = (unsigned)(end > 0 ? end - 1 : 0);
@ -2334,6 +2335,7 @@ static void xmb_list_open(xmb_handle_t *xmb)
xmb_list_open_old(xmb, &xmb->selection_buf_old,
dir, xmb->selection_ptr_old);
xmb_list_open_new(xmb, selection_buf,
dir, selection);
@ -3475,7 +3477,7 @@ static void xmb_draw_items(
core_node = xmb_get_userdata_from_horizontal_list(
xmb, (unsigned)(cat_selection_ptr - (xmb->system_tab_end + 1)));
end = list->size;
end = list ? list->size : 0;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0;