mirror of
https://github.com/libretro/RetroArch
synced 2025-02-19 12:41:00 +00:00
Merge pull request #3034 from sronsse/fixes_for_team
task overlay: Fix memory leak caused by overlay being loaded multiple…
This commit is contained in:
commit
427c73e7fd
@ -677,16 +677,40 @@ static void rarch_task_overlay_handler(retro_task_t *task)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool rarch_task_overlay_finder(retro_task_t *task, void *user_data)
|
||||||
|
{
|
||||||
|
overlay_loader_t *loader = NULL;
|
||||||
|
|
||||||
|
if (!task || (task->handler != rarch_task_overlay_handler))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!user_data)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
loader = (overlay_loader_t*)task->state;
|
||||||
|
if (!loader)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return string_is_equal(loader->overlay_path, (const char*)user_data);
|
||||||
|
}
|
||||||
|
|
||||||
static bool rarch_task_push_overlay_load(const char *overlay_path,
|
static bool rarch_task_push_overlay_load(const char *overlay_path,
|
||||||
retro_task_callback_t cb, void *user_data)
|
retro_task_callback_t cb, void *user_data)
|
||||||
{
|
{
|
||||||
retro_task_t *t = NULL;
|
retro_task_t *t = NULL;
|
||||||
config_file_t *conf = NULL;
|
config_file_t *conf = NULL;
|
||||||
overlay_loader_t *loader = (overlay_loader_t*)calloc(1, sizeof(*loader));
|
overlay_loader_t *loader = (overlay_loader_t*)calloc(1, sizeof(*loader));
|
||||||
|
task_finder_data_t find_data;
|
||||||
|
|
||||||
if (!loader)
|
if (!loader)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
/* Prevent overlay from being loaded if it already is being loaded */
|
||||||
|
find_data.func = rarch_task_overlay_finder;
|
||||||
|
find_data.userdata = (void*)overlay_path;
|
||||||
|
if (task_queue_ctl(TASK_QUEUE_CTL_FIND, &find_data))
|
||||||
|
goto error;
|
||||||
|
|
||||||
conf = config_file_new(overlay_path);
|
conf = config_file_new(overlay_path);
|
||||||
|
|
||||||
if (!conf)
|
if (!conf)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user