diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 48c76bb1b6..07d9af9c32 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -605,10 +605,8 @@ static void xmb_list_open_new(xmb_handle_t *xmb, xmb->old_depth = xmb->depth; } -static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, - core_info_t *info, unsigned i) +core_info_t *xmb_node_get_core_info(core_info_t *info, unsigned i) { - xmb_node_t *node = NULL; global_t *global = global_get_ptr(); core_info_list_t *info_list = global ? (core_info_list_t*)global->core_info : NULL; size_t list_size = info_list ? info_list->count : 0; @@ -622,6 +620,17 @@ static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, info = (core_info_t*)&info_list->list[i]; + if (!info) + return NULL; + return info; +} + +static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, + core_info_t *info, unsigned i) +{ + xmb_node_t *node = NULL; + info = xmb_node_get_core_info(info, i); + if (!info) return NULL; @@ -653,24 +662,12 @@ static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, core_info_t *info, unsigned i) { - global_t *global = global_get_ptr(); - core_info_list_t *info_list = global ? (core_info_list_t*)global->core_info : NULL; - size_t list_size = info_list ? info_list->count : 0; + info = xmb_node_get_core_info(info, i); - if (!info_list || list_size == 0) - return NULL; - rarch_assert(i >= 0); - rarch_assert(i <= list_size); - if (i >= list_size) - return NULL; + if (info) + return (xmb_node_t*)info->userdata; - info = (core_info_t*)&info_list->list[i]; - - if (!info) - return NULL; - - - return (xmb_node_t*)info->userdata; + return NULL; } static void xmb_push_animations(xmb_node_t *node, float ia, float ix)