mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-04 10:36:50 +00:00
(task_http.c) Cleanups/plug possible memory leaks
This commit is contained in:
parent
e8d86ef013
commit
1f039b53f3
@ -330,13 +330,16 @@ bool rarch_task_push_image_load(const char *fullpath, const char *type, rarch_ta
|
|||||||
}
|
}
|
||||||
|
|
||||||
nbio = (nbio_handle_t*)calloc(1, sizeof(*nbio));
|
nbio = (nbio_handle_t*)calloc(1, sizeof(*nbio));
|
||||||
|
|
||||||
|
if (!nbio)
|
||||||
|
return false;
|
||||||
|
|
||||||
nbio->handle = handle;
|
nbio->handle = handle;
|
||||||
nbio->is_finished = false;
|
nbio->is_finished = false;
|
||||||
nbio->cb = &cb_nbio_default;
|
nbio->cb = &cb_nbio_default;
|
||||||
nbio->status = NBIO_STATUS_TRANSFER;
|
nbio->status = NBIO_STATUS_TRANSFER;
|
||||||
nbio->image.status = NBIO_IMAGE_STATUS_TRANSFER;
|
nbio->image.status = NBIO_IMAGE_STATUS_TRANSFER;
|
||||||
|
|
||||||
|
|
||||||
if (cb_type_hash == CB_MENU_WALLPAPER)
|
if (cb_type_hash == CB_MENU_WALLPAPER)
|
||||||
nbio->cb = &cb_nbio_image_menu_wallpaper;
|
nbio->cb = &cb_nbio_image_menu_wallpaper;
|
||||||
else if (cb_type_hash == CB_MENU_BOXART)
|
else if (cb_type_hash == CB_MENU_BOXART)
|
||||||
@ -345,6 +348,13 @@ bool rarch_task_push_image_load(const char *fullpath, const char *type, rarch_ta
|
|||||||
nbio_begin_read(handle);
|
nbio_begin_read(handle);
|
||||||
|
|
||||||
t = (rarch_task_t*)calloc(1, sizeof(*t));
|
t = (rarch_task_t*)calloc(1, sizeof(*t));
|
||||||
|
|
||||||
|
if (!t)
|
||||||
|
{
|
||||||
|
free(nbio);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
t->state = nbio;
|
t->state = nbio;
|
||||||
t->handler = rarch_task_file_load_handler;
|
t->handler = rarch_task_file_load_handler;
|
||||||
t->callback = cb;
|
t->callback = cb;
|
||||||
|
@ -227,6 +227,10 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, rarch_task
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
http = (http_handle_t*)calloc(1, sizeof(*http));
|
http = (http_handle_t*)calloc(1, sizeof(*http));
|
||||||
|
|
||||||
|
if (!http)
|
||||||
|
return false;
|
||||||
|
|
||||||
http->connection.handle = conn;
|
http->connection.handle = conn;
|
||||||
http->connection.cb = &cb_http_conn_default;
|
http->connection.cb = &cb_http_conn_default;
|
||||||
|
|
||||||
@ -235,15 +239,22 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, rarch_task
|
|||||||
|
|
||||||
http->status = HTTP_STATUS_CONNECTION_TRANSFER;
|
http->status = HTTP_STATUS_CONNECTION_TRANSFER;
|
||||||
|
|
||||||
t = (rarch_task_t*)calloc(1, sizeof(*t));
|
t = (rarch_task_t*)calloc(1, sizeof(*t));
|
||||||
t->handler = rarch_task_http_transfer_handler;
|
|
||||||
t->state = http;
|
if (!t)
|
||||||
t->callback = cb;
|
{
|
||||||
t->user_data = user_data;
|
free(http);
|
||||||
t->progress = -1;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
t->handler = rarch_task_http_transfer_handler;
|
||||||
|
t->state = http;
|
||||||
|
t->callback = cb;
|
||||||
|
t->user_data = user_data;
|
||||||
|
t->progress = -1;
|
||||||
|
|
||||||
snprintf(tmp, sizeof(tmp), "%s '%s'", msg_hash_to_str(MSG_DOWNLOADING), path_basename(url));
|
snprintf(tmp, sizeof(tmp), "%s '%s'", msg_hash_to_str(MSG_DOWNLOADING), path_basename(url));
|
||||||
t->title = strdup(tmp);
|
t->title = strdup(tmp);
|
||||||
|
|
||||||
rarch_task_push(t);
|
rarch_task_push(t);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user