From: ticktock35 Date: Wed, 17 Dec 2008 00:27:04 +0000 (+0000) Subject: move pkg_compare_name to pkg_vec and remove qsort in hash_get X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5f04cd13dd57779aa0828b0cd9d4181f1e7afc95;p=oweals%2Fopkg-lede.git move pkg_compare_name to pkg_vec and remove qsort in hash_get git-svn-id: http://opkg.googlecode.com/svn/trunk@183 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c index 2bb9372..af6c4b7 100644 --- a/libopkg/opkg_cmd.c +++ b/libopkg/opkg_cmd.c @@ -756,6 +756,7 @@ static int opkg_list_installed_cmd(opkg_conf_t *conf, int argc, char **argv) } available = pkg_vec_alloc(); pkg_hash_fetch_all_installed(&conf->pkg_hash, available); + pkg_vec_sort(available, pkg_compare_names); for (i=0; i < available->len; i++) { pkg = available->pkgs[i]; /* if we have package name or pattern and pkg does not match, then skip it */ diff --git a/libopkg/pkg.c b/libopkg/pkg.c index dde3a19..309af55 100644 --- a/libopkg/pkg.c +++ b/libopkg/pkg.c @@ -113,7 +113,6 @@ int pkg_init(pkg_t *pkg) pkg->recommends_count = 0; active_list_init(&pkg->list); - active_list_init(&pkg->searched_node); /* Abhaya: added init for conflicts fields */ pkg->conflicts = NULL; @@ -453,7 +452,6 @@ int abstract_pkg_init(abstract_pkg_t *ab_pkg) } ab_pkg->dependencies_checked = 0; ab_pkg->state_status = SS_NOT_INSTALLED; - active_list_init(&ab_pkg->searched_node); return 0; } diff --git a/libopkg/pkg.h b/libopkg/pkg.h index 3f7d6b6..a7c98ec 100644 --- a/libopkg/pkg.h +++ b/libopkg/pkg.h @@ -88,7 +88,6 @@ struct abstract_pkg{ struct abstract_pkg ** depended_upon_by; /* @@@@ this should be abstract_pkg_vec_t -Jamey */ abstract_pkg_vec_t * provided_by; abstract_pkg_vec_t * replaced_by; - struct active_list searched_node; /* Used for hash search */ }; #include "pkg_depends.h" @@ -138,7 +137,6 @@ struct pkg char **suggests_str; int suggests_count; struct active_list list; /* Used for installing|upgrading */ - struct active_list searched_node; /* Used for searching */ compound_depend_t * depends; /* Abhaya: new conflicts */ diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c index aaa6974..ed8006d 100644 --- a/libopkg/pkg_hash.c +++ b/libopkg/pkg_hash.c @@ -203,7 +203,6 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(opkg_conf_t *conf, abstract_pk for (i = 0; i < nprovides; i++) { abstract_pkg_t *provider_apkg = provided_apkgs[i]; opkg_message(conf, OPKG_DEBUG, " adding %s to providers\n", provider_apkg->name); - printf(" adding %s to providers\n", provider_apkg->name); abstract_pkg_vec_insert(providers, provider_apkg); } nprovides = providers->len; @@ -460,17 +459,6 @@ pkg_vec_t *pkg_vec_fetch_by_name(hash_table_t *hash, const char *pkg_name) } } -static int pkg_compare_names(const void *p1, const void *p2) -{ - const pkg_t *pkg1 = *(const pkg_t **)p1; - const pkg_t *pkg2 = *(const pkg_t **)p2; - if (pkg1->name == NULL) - return 1; - if (pkg2->name == NULL) - return -1; - return(strcmp(pkg1->name, pkg2->name)); -} - static void pkg_hash_fetch_available_helper(const char *pkg_name, void *entry, void *data) { @@ -489,7 +477,7 @@ static void pkg_hash_fetch_available_helper(const char *pkg_name, void *entry, v void pkg_hash_fetch_available(hash_table_t *hash, pkg_vec_t *all) { hash_table_foreach(hash, pkg_hash_fetch_available_helper, all); - qsort(all->pkgs, all->len, sizeof(pkg_t *), pkg_compare_names); + //qsort(all->pkgs, all->len, sizeof(pkg_t *), pkg_compare_names); } static void pkg_hash_fetch_all_installed_helper(const char *pkg_name, void *entry, void *data) @@ -510,7 +498,7 @@ static void pkg_hash_fetch_all_installed_helper(const char *pkg_name, void *entr void pkg_hash_fetch_all_installed(hash_table_t *hash, pkg_vec_t *all) { hash_table_foreach(hash, pkg_hash_fetch_all_installed_helper, all); - qsort(all->pkgs, all->len, sizeof(void*), pkg_compare_names); + //qsort(all->pkgs, all->len, sizeof(void*), pkg_compare_names); } static void pkg_hash_dump_helper(const char *pkg_name, void *entry, void *data) diff --git a/libopkg/pkg_vec.c b/libopkg/pkg_vec.c index 84b9799..4c2200b 100644 --- a/libopkg/pkg_vec.c +++ b/libopkg/pkg_vec.c @@ -209,3 +209,14 @@ void abstract_pkg_vec_sort(pkg_vec_t *vec, compare_fcn_t compar) qsort(vec->pkgs, vec->len, sizeof(pkg_t *), compar); } +int pkg_compare_names(const void *p1, const void *p2) +{ + const pkg_t *pkg1 = *(const pkg_t **)p1; + const pkg_t *pkg2 = *(const pkg_t **)p2; + if (pkg1->name == NULL) + return 1; + if (pkg2->name == NULL) + return -1; + return(strcmp(pkg1->name, pkg2->name)); +} + diff --git a/libopkg/pkg_vec.h b/libopkg/pkg_vec.h index 0ec7489..0f9aac6 100644 --- a/libopkg/pkg_vec.h +++ b/libopkg/pkg_vec.h @@ -61,5 +61,7 @@ void abstract_pkg_vec_insert(abstract_pkg_vec_t *vec, abstract_pkg_t *pkg); abstract_pkg_t * abstract_pkg_vec_get(abstract_pkg_vec_t *vec, int i); int abstract_pkg_vec_contains(abstract_pkg_vec_t *vec, abstract_pkg_t *apkg); void abstract_pkg_vec_sort(pkg_vec_t *vec, compare_fcn_t compar); + +int pkg_compare_names(const void *p1, const void *p2); #endif