[pacman-dev] [PATCH 1/3] Initialize cURL library on first use
Rather than always initializing it on any handle creation. There are several frontend operations (search, info, etc.) that never need the download code, so spending time initializing this every single time is a bit silly. This makes it a bit more like the GPGME code init path. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/alpm.c | 5 --- lib/libalpm/dload.c | 77 ++++++++++++++++++++++++++++---------------------- lib/libalpm/dload.h | 1 + lib/libalpm/handle.h | 1 - 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 772c84d..3884334 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -78,11 +78,6 @@ alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath, bindtextdomain("libalpm", LOCALEDIR); #endif -#ifdef HAVE_LIBCURL - curl_global_init(CURL_GLOBAL_SSL); - myhandle->curl = curl_easy_init(); -#endif - return myhandle; cleanup: diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 1e8db1e..dbf7a8c 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -66,6 +66,15 @@ static char *get_fullpath(const char *path, const char *filename, return filepath; } +static CURL *get_libcurl_handle(alpm_handle_t *handle) +{ + if(!handle->curl) { + curl_global_init(CURL_GLOBAL_SSL); + handle->curl = curl_easy_init(); + } + return handle->curl; +} + enum { ABORT_SIGINT = 1, ABORT_OVER_MAXFILESIZE @@ -201,7 +210,7 @@ static size_t parse_headers(void *ptr, size_t size, size_t nmemb, void *user) } static void curl_set_handle_opts(struct dload_payload *payload, - char *error_buffer) + CURL *curl, char *error_buffer) { alpm_handle_t *handle = payload->handle; const char *useragent = getenv("HTTP_USER_AGENT"); @@ -209,47 +218,46 @@ static void curl_set_handle_opts(struct dload_payload *payload, /* the curl_easy handle is initialized with the alpm handle, so we only need * to reset the handle's parameters for each time it's used. */ - curl_easy_reset(handle->curl); - curl_easy_setopt(handle->curl, CURLOPT_URL, payload->fileurl); - curl_easy_setopt(handle->curl, CURLOPT_FAILONERROR, 1L); - curl_easy_setopt(handle->curl, CURLOPT_ERRORBUFFER, error_buffer); - curl_easy_setopt(handle->curl, CURLOPT_CONNECTTIMEOUT, 10L); - curl_easy_setopt(handle->curl, CURLOPT_FILETIME, 1L); - curl_easy_setopt(handle->curl, CURLOPT_NOPROGRESS, 0L); - curl_easy_setopt(handle->curl, CURLOPT_FOLLOWLOCATION, 1L); - curl_easy_setopt(handle->curl, CURLOPT_PROGRESSFUNCTION, curl_progress); - curl_easy_setopt(handle->curl, CURLOPT_PROGRESSDATA, (void *)payload); - curl_easy_setopt(handle->curl, CURLOPT_LOW_SPEED_LIMIT, 1024L); - curl_easy_setopt(handle->curl, CURLOPT_LOW_SPEED_TIME, 10L); - curl_easy_setopt(handle->curl, CURLOPT_HEADERFUNCTION, parse_headers); - curl_easy_setopt(handle->curl, CURLOPT_WRITEHEADER, (void *)payload); - curl_easy_setopt(handle->curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); + curl_easy_reset(curl); + curl_easy_setopt(curl, CURLOPT_URL, payload->fileurl); + curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L); + curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buffer); + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L); + curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, curl_progress); + curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void *)payload); + curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1024L); + curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L); + curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, parse_headers); + curl_easy_setopt(curl, CURLOPT_WRITEHEADER, (void *)payload); + curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); _alpm_log(handle, ALPM_LOG_DEBUG, "url: %s\n", payload->fileurl); if(payload->max_size) { _alpm_log(handle, ALPM_LOG_DEBUG, "maxsize: %jd\n", (intmax_t)payload->max_size); - curl_easy_setopt(handle->curl, CURLOPT_MAXFILESIZE_LARGE, + curl_easy_setopt(curl, CURLOPT_MAXFILESIZE_LARGE, (curl_off_t)payload->max_size); } if(useragent != NULL) { - curl_easy_setopt(handle->curl, CURLOPT_USERAGENT, useragent); + curl_easy_setopt(curl, CURLOPT_USERAGENT, useragent); } if(!payload->allow_resume && !payload->force && payload->destfile_name && stat(payload->destfile_name, &st) == 0) { /* start from scratch, but only download if our local is out of date. */ - curl_easy_setopt(handle->curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE); - curl_easy_setopt(handle->curl, CURLOPT_TIMEVALUE, (long)st.st_mtime); + curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE); + curl_easy_setopt(curl, CURLOPT_TIMEVALUE, (long)st.st_mtime); _alpm_log(handle, ALPM_LOG_DEBUG, "using time condition: %lu\n", (long)st.st_mtime); } else if(stat(payload->tempfile_name, &st) == 0 && payload->allow_resume) { /* a previous partial download exists, resume from end of file. */ payload->tempfile_openmode = "ab"; - curl_easy_setopt(handle->curl, CURLOPT_RESUME_FROM_LARGE, - (curl_off_t)st.st_size); + curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, (curl_off_t)st.st_size); _alpm_log(handle, ALPM_LOG_DEBUG, "tempfile found, attempting continuation from %jd bytes\n", (intmax_t)st.st_size); @@ -319,6 +327,7 @@ static int curl_download_internal(struct dload_payload *payload, struct sigaction orig_sig_pipe, orig_sig_int; /* shortcut to our handle within the payload */ alpm_handle_t *handle = payload->handle; + CURL *curl = get_libcurl_handle(handle); handle->pm_errno = 0; payload->tempfile_openmode = "wb"; @@ -347,7 +356,7 @@ static int curl_download_internal(struct dload_payload *payload, } } - curl_set_handle_opts(payload, error_buffer); + curl_set_handle_opts(payload, curl, error_buffer); if(localf == NULL) { localf = fopen(payload->tempfile_name, payload->tempfile_openmode); @@ -360,7 +369,7 @@ static int curl_download_internal(struct dload_payload *payload, "opened tempfile for download: %s (%s)\n", payload->tempfile_name, payload->tempfile_openmode); - curl_easy_setopt(handle->curl, CURLOPT_WRITEDATA, localf); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, localf); /* ignore any SIGPIPE signals- these may occur if our FTP socket dies or * something along those lines. Store the old signal handler first. */ @@ -371,16 +380,16 @@ static int curl_download_internal(struct dload_payload *payload, prevprogress = 0; /* perform transfer */ - handle->curlerr = curl_easy_perform(handle->curl); + payload->curlerr = curl_easy_perform(curl); /* immediately unhook the progress callback */ - curl_easy_setopt(handle->curl, CURLOPT_NOPROGRESS, 1L); + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L); /* was it a success? */ - switch(handle->curlerr) { + switch(payload->curlerr) { case CURLE_OK: /* get http/ftp response code */ - curl_easy_getinfo(handle->curl, CURLINFO_RESPONSE_CODE, &respcode); + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &respcode); if(respcode >=400) { payload->unlink_on_fail = 1; goto cleanup; @@ -389,7 +398,7 @@ static int curl_download_internal(struct dload_payload *payload, case CURLE_ABORTED_BY_CALLBACK: /* handle the interrupt accordingly */ if(dload_interrupted == ABORT_OVER_MAXFILESIZE) { - handle->curlerr = CURLE_FILESIZE_EXCEEDED; + payload->curlerr = CURLE_FILESIZE_EXCEEDED; handle->pm_errno = ALPM_ERR_LIBCURL; /* the hardcoded 'size exceeded' message is same as libcurl's normal */ _alpm_log(handle, ALPM_LOG_ERROR, @@ -416,11 +425,11 @@ static int curl_download_internal(struct dload_payload *payload, } /* retrieve info about the state of the transfer */ - curl_easy_getinfo(handle->curl, CURLINFO_FILETIME, &remote_time); - curl_easy_getinfo(handle->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &remote_size); - curl_easy_getinfo(handle->curl, CURLINFO_SIZE_DOWNLOAD, &bytes_dl); - curl_easy_getinfo(handle->curl, CURLINFO_CONDITION_UNMET, &timecond); - curl_easy_getinfo(handle->curl, CURLINFO_EFFECTIVE_URL, &effective_url); + curl_easy_getinfo(curl, CURLINFO_FILETIME, &remote_time); + curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &remote_size); + curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &bytes_dl); + curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &timecond); + curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effective_url); /* time condition was met and we didn't download anything. we need to * clean up the 0 byte .part file that's left behind. */ diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h index 765c5fd..c2fd609 100644 --- a/lib/libalpm/dload.h +++ b/lib/libalpm/dload.h @@ -39,6 +39,7 @@ struct dload_payload { int allow_resume; int errors_ok; int unlink_on_fail; + CURLcode curlerr; /* last error produced by curl */ }; void _alpm_dload_payload_free(struct dload_payload *payload); diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h index b1d70d2..8477dca 100644 --- a/lib/libalpm/handle.h +++ b/lib/libalpm/handle.h @@ -60,7 +60,6 @@ struct __alpm_handle_t { #ifdef HAVE_LIBCURL /* libcurl handle */ CURL *curl; /* reusable curl_easy handle */ - CURLcode curlerr; /* last error produced by curl */ #endif /* callback functions */ -- 1.7.6.4
This was done to squash a memory leak in the sync database download code. When we downloaded a database and then reused the payload struct, we could find ourselves calling get_fullpath() for the signatures and overwriting non-freed values we had left over from the database download. Refactor the payload_free function into a payload_reset function that we can call that does NOT free the payload itself, so we can reuse payload structs. This also allows us to move the payload to the stack in some call paths, relieving us of the need to alloc space. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/be_sync.c | 42 ++++++++++++++++++++++------------------ lib/libalpm/dload.c | 50 ++++++++++++++++++++++++------------------------ lib/libalpm/dload.h | 2 +- lib/libalpm/sync.c | 5 +-- 4 files changed, 51 insertions(+), 48 deletions(-) diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 53777d9..e9e816c 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -201,24 +201,25 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db) for(i = db->servers; i; i = i->next) { const char *server = i->data; - struct dload_payload *payload; + struct dload_payload payload; size_t len; int sig_ret = 0; - CALLOC(payload, 1, sizeof(*payload), RET_ERR(handle, ALPM_ERR_MEMORY, -1)); + memset(&payload, 0, sizeof(struct dload_payload)); /* set hard upper limit of 25MiB */ - payload->max_size = 25 * 1024 * 1024; + payload.max_size = 25 * 1024 * 1024; - /* print server + filename into a buffer (leave space for .sig) */ - len = strlen(server) + strlen(db->treename) + 9; - CALLOC(payload->fileurl, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, -1)); - snprintf(payload->fileurl, len, "%s/%s.db", server, db->treename); - payload->handle = handle; - payload->force = force; - payload->unlink_on_fail = 1; + /* print server + filename into a buffer */ + len = strlen(server) + strlen(db->treename) + 5; + MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); + snprintf(payload.fileurl, len, "%s/%s.db", server, db->treename); + payload.handle = handle; + payload.force = force; + payload.unlink_on_fail = 1; - ret = _alpm_download(payload, syncpath, NULL); + ret = _alpm_download(&payload, syncpath, NULL); + _alpm_dload_payload_reset(&payload); if(ret == 0 && (level & ALPM_SIG_DATABASE)) { /* an existing sig file is no good at this point */ @@ -231,20 +232,23 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db) free(sigpath); /* if we downloaded a DB, we want the .sig from the same server */ - snprintf(payload->fileurl, len, "%s/%s.db.sig", server, db->treename); - payload->handle = handle; - payload->force = 1; - payload->errors_ok = (level & ALPM_SIG_DATABASE_OPTIONAL); + /* print server + filename into a buffer (leave space for .sig) */ + len = strlen(server) + strlen(db->treename) + 9; + MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); + snprintf(payload.fileurl, len, "%s/%s.db.sig", server, db->treename); + payload.handle = handle; + payload.force = 1; + payload.errors_ok = (level & ALPM_SIG_DATABASE_OPTIONAL); /* set hard upper limit of 16KiB */ - payload->max_size = 16 * 1024; + payload.max_size = 16 * 1024; - sig_ret = _alpm_download(payload, syncpath, NULL); + sig_ret = _alpm_download(&payload, syncpath, NULL); /* errors_ok suppresses error messages, but not the return code */ - sig_ret = payload->errors_ok ? 0 : sig_ret; + sig_ret = payload.errors_ok ? 0 : sig_ret; + _alpm_dload_payload_reset(&payload); } - _alpm_dload_payload_free(payload); if(ret != -1 && sig_ret != -1) { break; } diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index dbf7a8c..c599b7f 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -390,7 +390,7 @@ static int curl_download_internal(struct dload_payload *payload, case CURLE_OK: /* get http/ftp response code */ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &respcode); - if(respcode >=400) { + if(respcode >= 400) { payload->unlink_on_fail = 1; goto cleanup; } @@ -546,7 +546,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url) char *filepath; const char *cachedir; char *final_file = NULL; - struct dload_payload *payload; + struct dload_payload payload; int ret; CHECK_HANDLE(handle, return NULL); @@ -555,15 +555,17 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url) /* find a valid cache dir to download to */ cachedir = _alpm_filecache_setup(handle); - CALLOC(payload, 1, sizeof(*payload), RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); - payload->handle = handle; - STRDUP(payload->fileurl, url, RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); - payload->allow_resume = 1; + memset(&payload, 0, sizeof(struct dload_payload)); + payload.handle = handle; + STRDUP(payload.fileurl, url, RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); + payload.allow_resume = 1; /* download the file */ - ret = _alpm_download(payload, cachedir, &final_file); + ret = _alpm_download(&payload, cachedir, &final_file); + _alpm_dload_payload_reset(&payload); if(ret == -1) { _alpm_log(handle, ALPM_LOG_WARNING, _("failed to download %s\n"), url); + free(final_file); return NULL; } _alpm_log(handle, ALPM_LOG_DEBUG, "successfully downloaded %s\n", url); @@ -572,37 +574,37 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url) if(ret == 0 && (handle->siglevel & ALPM_SIG_PACKAGE)) { char *sig_final_file = NULL; size_t len; - struct dload_payload *sig_payload; - CALLOC(sig_payload, 1, sizeof(*sig_payload), RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); len = strlen(url) + 5; - CALLOC(sig_payload->fileurl, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); - snprintf(sig_payload->fileurl, len, "%s.sig", url); - sig_payload->handle = handle; - sig_payload->force = 1; - sig_payload->errors_ok = (handle->siglevel & ALPM_SIG_PACKAGE_OPTIONAL); - - ret = _alpm_download(sig_payload, cachedir, &sig_final_file); - if(ret == -1 && !sig_payload->errors_ok) { - _alpm_log(handle, ALPM_LOG_WARNING, _("failed to download %s\n"), sig_payload->fileurl); + MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); + snprintf(payload.fileurl, len, "%s.sig", url); + payload.handle = handle; + payload.force = 1; + payload.errors_ok = (handle->siglevel & ALPM_SIG_PACKAGE_OPTIONAL); + + ret = _alpm_download(&payload, cachedir, &sig_final_file); + if(ret == -1 && !payload.errors_ok) { + _alpm_log(handle, ALPM_LOG_WARNING, + _("failed to download %s\n"), payload.fileurl); /* Warn now, but don't return NULL. We will fail later during package * load time. */ } else if(ret == 0) { - _alpm_log(handle, ALPM_LOG_DEBUG, "successfully downloaded %s\n", sig_payload->fileurl); + _alpm_log(handle, ALPM_LOG_DEBUG, + "successfully downloaded %s\n", payload.fileurl); } FREE(sig_final_file); - _alpm_dload_payload_free(sig_payload); + _alpm_dload_payload_reset(&payload); } /* we should be able to find the file the second time around */ filepath = _alpm_filecache_find(handle, final_file); - FREE(final_file); - _alpm_dload_payload_free(payload); + free(final_file); return filepath; } -void _alpm_dload_payload_free(struct dload_payload *payload) { +void _alpm_dload_payload_reset(struct dload_payload *payload) +{ ASSERT(payload, return); FREE(payload->remote_name); @@ -610,8 +612,6 @@ void _alpm_dload_payload_free(struct dload_payload *payload) { FREE(payload->destfile_name); FREE(payload->content_disp_name); FREE(payload->fileurl); - FREE(payload); - } /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h index c2fd609..9be29bc 100644 --- a/lib/libalpm/dload.h +++ b/lib/libalpm/dload.h @@ -42,7 +42,7 @@ struct dload_payload { CURLcode curlerr; /* last error produced by curl */ }; -void _alpm_dload_payload_free(struct dload_payload *payload); +void _alpm_dload_payload_reset(struct dload_payload *payload); int _alpm_download(struct dload_payload *payload, const char *localpath, char **final_file); diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 8c50ec8..08d634d 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -891,9 +891,8 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas) } } - alpm_list_free_inner(files, (alpm_list_fn_free)_alpm_dload_payload_free); - alpm_list_free(files); - files = NULL; + alpm_list_free_inner(files, (alpm_list_fn_free)_alpm_dload_payload_reset); + FREELIST(files); } } -- 1.7.6.4
This also fixes a memory leak and makes the dual-purpose "rows" variable go away in favor of storing the rows and non-verbose names separately. This also fixes some potential memory leaks and/or wrong behavior due to the config->verbosepkglists flag being flipped, which we should never be doing. Signed-off-by: Dan McGee <dan@archlinux.org> --- src/pacman/util.c | 59 +++++++++++++++++++++++----------------------------- 1 files changed, 26 insertions(+), 33 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index 748c0e9..6b6463e 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -817,13 +817,13 @@ static alpm_list_t *create_verbose_row(pm_target_t *target, int dl_size) } /* prepare a list of pkgs to display */ -static void _display_targets(alpm_list_t *targets) +static void _display_targets(alpm_list_t *targets, int verbose) { char *str; const char *label; double size; off_t isize = 0, rsize = 0, dlsize = 0; - alpm_list_t *i, *header = NULL, *rows = NULL; + alpm_list_t *i, *rows = NULL, *names = NULL; int show_dl_size = config->op == PM_OP_SYNC; if(!targets) { @@ -843,36 +843,43 @@ static void _display_targets(alpm_list_t *targets) rsize += alpm_pkg_get_isize(target->remove); } - if(config->verbosepkglists) { - rows = alpm_list_add(rows, create_verbose_row(target, show_dl_size)); + /* form data for both verbose and non-verbose display */ + rows = alpm_list_add(rows, create_verbose_row(target, show_dl_size)); + if(target->install) { + pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(target->install), + alpm_pkg_get_version(target->install)); } else { - if(target->install) { - pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(target->install), - alpm_pkg_get_version(target->install)); - } else { - pm_asprintf(&str, "%s-%s [removal]", alpm_pkg_get_name(target->remove), - alpm_pkg_get_version(target->remove)); - } - rows = alpm_list_add(rows, str); + pm_asprintf(&str, "%s-%s [removal]", alpm_pkg_get_name(target->remove), + alpm_pkg_get_version(target->remove)); } + names = alpm_list_add(names, str); } /* print to screen */ pm_asprintf(&str, _("Targets (%d):"), alpm_list_count(targets)); printf("\n"); - if(config->verbosepkglists) { - header = create_verbose_header(show_dl_size); + if(verbose) { + alpm_list_t *header = create_verbose_header(show_dl_size); if(table_display(str, header, rows) != 0) { - config->verbosepkglists = 0; - _display_targets(targets); - goto out; + /* fallback to list display if table wouldn't fit */ + list_display(str, names); } + alpm_list_free(header); } else { - list_display(str, rows); + list_display(str, names); } printf("\n"); + /* rows is a list of lists of strings, free inner lists here */ + for(i = rows; i; i = alpm_list_next(i)) { + alpm_list_t *lp = alpm_list_getdata(i); + FREELIST(lp); + } + alpm_list_free(rows); + FREELIST(names); + free(str); + if(dlsize > 0 || config->op_s_downloadonly) { size = humanize_size(dlsize, 'M', &label); printf(_("Total Download Size: %.2f %s\n"), size, label); @@ -892,20 +899,6 @@ static void _display_targets(alpm_list_t *targets) printf(_("Net Upgrade Size: %.2f %s\n"), size, label); } } - -out: - /* cleanup */ - if(config->verbosepkglists) { - /* rows is a list of lists of strings, free inner lists here */ - for(i = rows; i; i = alpm_list_next(i)) { - alpm_list_t *lp = alpm_list_getdata(i); - FREELIST(lp); - } - alpm_list_free(header); - } else { - FREELIST(rows); - } - free(str); } static int target_cmp(const void *p1, const void *p2) @@ -959,7 +952,7 @@ void display_targets(void) } targets = alpm_list_msort(targets, alpm_list_count(targets), target_cmp); - _display_targets(targets); + _display_targets(targets, config->verbosepkglists); FREELIST(targets); } -- 1.7.6.4
participants (1)
-
Dan McGee