From 58e81410fbb586cf21c874fc5b616d26c6851a8d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Mar 2015 15:32:50 +0100 Subject: [PATCH] (XMB) Split xmb_get_userdata_from_core up into two functions --- menu/drivers/xmb.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index ac461736f3..f3cc8da3ff 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -694,28 +694,13 @@ static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, siz xmb->old_depth = xmb->depth; } -static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, int i) +static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, core_info_t *info, int i) { - core_info_t *info = NULL; xmb_node_t *node = NULL; - core_info_list_t *info_list = (core_info_list_t*)g_extern.core_info; - - if (!info_list) - return NULL; - - if (!info_list->count) - return NULL; - - info = (core_info_t*)&info_list->list[i]; if (!info) return NULL; - - node = (xmb_node_t*)info->userdata; - - if (node) - return node; - + info->userdata = (xmb_node_t*)calloc(1, sizeof(xmb_node_t)); if (!info->userdata) @@ -741,6 +726,30 @@ static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, int i) return node; } +static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, int i) +{ + core_info_t *info = NULL; + xmb_node_t *node = NULL; + core_info_list_t *info_list = (core_info_list_t*)g_extern.core_info; + + if (!info_list) + return NULL; + if (!info_list->count) + return NULL; + + info = (core_info_t*)&info_list->list[i]; + + if (!info) + return NULL; + + node = (xmb_node_t*)info->userdata; + + if (!node) + return xmb_node_allocate_userdata(xmb, info, i); + + return node; +} + static void xmb_push_animations(xmb_node_t *node, float ia, float ix) { menu_handle_t *menu = menu_driver_resolve();