1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-12 04:25:08 -05:00

tool_operate: Moved easy handle cleanup into tool_main

This commit is contained in:
Steve Holme 2014-02-23 15:10:18 +00:00
parent 0af2322bc6
commit c27cc68815
3 changed files with 9 additions and 22 deletions

View File

@ -154,19 +154,13 @@ void config_free(struct OperationConfig *config)
{ {
struct OperationConfig *last = config; struct OperationConfig *last = config;
/* Find the last config structure */
while(last->next)
last = last->next;
/* Free each of the structures in reverse order */ /* Free each of the structures in reverse order */
do { while(last) {
struct OperationConfig *prev = last->prev; struct OperationConfig *prev = last->prev;
if(prev)
last->easy = NULL;
free_config_fields(last); free_config_fields(last);
free(last); free(last);
last = prev; last = prev;
} while(last); }
} }

View File

@ -172,13 +172,17 @@ static CURLcode main_init(struct GlobalConfig *config)
*/ */
static void main_free(struct GlobalConfig *config) static void main_free(struct GlobalConfig *config)
{ {
/* Cleanup the easy handle */
curl_easy_cleanup(config->easy);
config->easy = NULL;
/* Main cleanup */ /* Main cleanup */
curl_global_cleanup(); curl_global_cleanup();
convert_cleanup(); convert_cleanup();
metalink_cleanup(); metalink_cleanup();
/* Free the config structures */ /* Free the config structures */
config_free(config->first); config_free(config->last);
config->first = NULL; config->first = NULL;
config->last = NULL; config->last = NULL;
} }

View File

@ -1772,18 +1772,10 @@ static CURLcode operate_do(struct OperationConfig *config)
dumpeasysrc(config); dumpeasysrc(config);
#endif #endif
return (CURLcode)res;
}
static void operate_free(struct OperationConfig *config)
{
if(config->easy) {
curl_easy_cleanup(config->easy);
config->easy = NULL;
}
/* Release metalink related resources here */ /* Release metalink related resources here */
clean_metalink(config); clean_metalink(config);
return (CURLcode)res;
} }
CURLcode operate(struct GlobalConfig *config, int argc, argv_item_t argv[]) CURLcode operate(struct GlobalConfig *config, int argc, argv_item_t argv[])
@ -1851,8 +1843,5 @@ CURLcode operate(struct GlobalConfig *config, int argc, argv_item_t argv[])
} }
} }
/* Perform the cleanup */
operate_free(config->first);
return result; return result;
} }