(Menu explore) jdgleaver's memory leak fixes

This commit is contained in:
twinaphex 2020-07-28 14:32:46 +02:00
parent 89bc5d9c0c
commit 395de4bae5
3 changed files with 20 additions and 7 deletions

View File

@ -474,6 +474,8 @@ void menu_display_handle_wallpaper_upload(retro_task_t *task,
void *task_data,
void *user_data, const char *err);
void menu_explore_free(void);
menu_handle_t *menu_driver_get_ptr(void);
enum action_iterate_type

View File

@ -499,12 +499,7 @@ static void explore_build_list(void)
const char *directory_database = settings->paths.path_content_database;
libretro_vfs_implementation_dir *dir = NULL;
if (explore_state)
{
explore_free(explore_state);
free(explore_state);
explore_state = NULL;
}
menu_explore_free();
explore_state = (explore_state_t*)calloc(
1, sizeof(explore_state_t));
@ -744,7 +739,10 @@ static void explore_build_list(void)
{
uint32_t idx;
size_t len = EX_BUF_LEN(explore_state->by[i]);
qsort(explore_state->by[i], len, sizeof(*explore_state->by[i]), explore_qsort_func_strings);
if (explore_state->by[i])
qsort(explore_state->by[i], len, sizeof(*explore_state->by[i]), explore_qsort_func_strings);
for (idx = 0; idx != len; idx++)
explore_state->by[i][idx]->idx = idx;
@ -1161,3 +1159,13 @@ SKIP_ENTRY:;
return list->size;
}
void menu_explore_free(void)
{
if (explore_state)
{
explore_free(explore_state);
free(explore_state);
explore_state = NULL;
}
}

View File

@ -7355,6 +7355,9 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
#ifdef HAVE_NETWORKING
core_updater_list_free_cached();
#endif
#ifdef HAVE_LIBRETRODB
menu_explore_free();
#endif
if (p_rarch->menu_driver_data)
{