/* * This is the main global destructor for the app. Call this after * _all_ libcurl usage is done. */ static void main_free(struct GlobalConfig *config) { /* Cleanup the easy handle */ curl_easy_cleanup(config->easy); config->easy = NULL; /* Main cleanup */ curl_global_cleanup(); convert_cleanup(); metalink_cleanup(); #ifdef USE_NSS if(PR_Initialized()) { /* prevent valgrind from reporting still reachable mem from NSRP arenas */ PL_ArenaFinish(); /* prevent valgrind from reporting possibly lost memory (fd cache, ...) */ PR_Cleanup(); } #endif free_config_fields(config); /* Free the config structures */ config_free(config->last); config->first = NULL; config->last = NULL; }
/* ** curl tool main function. */ int main(int argc, char *argv[]) { int res; struct Configurable config; /* Initialise the config */ init_config(&config); main_checkfds(); #if defined(HAVE_SIGNAL) && defined(SIGPIPE) (void)signal(SIGPIPE, SIG_IGN); #endif res = operate(&config, argc, argv); #ifdef __SYMBIAN32__ if(config.showerror) tool_pressanykey(); #endif free_config_fields(&config); #ifdef __NOVELL_LIBC__ if(getenv("_IN_NETWARE_BASH_") == NULL) tool_pressanykey(); #endif #ifdef __VMS vms_special_exit(res, vms_show); #else return res; #endif }
void config_free(struct OperationConfig *config) { struct OperationConfig *last = config; /* Free each of the structures in reverse order */ while(last) { struct OperationConfig *prev = last->prev; free_config_fields(last); free(last); last = prev; } }