mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-15 06:58:34 +00:00
Add cleanup handler for tasks to free allocated resources after the task finished.
This commit is contained in:
parent
4c3281bd39
commit
845dcef6ab
@ -123,6 +123,10 @@ struct retro_task
|
||||
/* always called from the main loop */
|
||||
retro_task_callback_t callback;
|
||||
|
||||
/* task cleanup handler to free allocated resources, will
|
||||
* be called immediately after running the main callback */
|
||||
retro_task_handler_t cleanup;
|
||||
|
||||
/* set to true by the handler to signal
|
||||
* the task has finished executing. */
|
||||
bool finished;
|
||||
|
@ -126,6 +126,9 @@ static void retro_task_internal_gather(void)
|
||||
if (task->callback)
|
||||
task->callback(task->task_data, task->user_data, task->error);
|
||||
|
||||
if (task->cleanup)
|
||||
task->cleanup(task);
|
||||
|
||||
if (task->error)
|
||||
free(task->error);
|
||||
|
||||
|
@ -383,6 +383,7 @@ bool rarch_task_push_image_load(const char *fullpath,
|
||||
|
||||
t->state = nbio;
|
||||
t->handler = rarch_task_file_load_handler;
|
||||
t->cleanup = rarch_task_image_load_free;
|
||||
t->callback = cb;
|
||||
t->user_data = user_data;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user