move pkg_compare_name to pkg_vec and remove qsort in hash_get
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Wed, 17 Dec 2008 00:27:04 +0000 (00:27 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Wed, 17 Dec 2008 00:27:04 +0000 (00:27 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@183 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/opkg_cmd.c
libopkg/pkg.c
libopkg/pkg.h
libopkg/pkg_hash.c
libopkg/pkg_vec.c
libopkg/pkg_vec.h

index 2bb93727248a7e208a73f58ff8ede3dde6d87fd5..af6c4b7c7f6861c37f227e5c7a538e971e6ee492 100644 (file)
@@ -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 */
index dde3a19f22ad5ea83ec98eaed425af2ecf3df647..309af55db1ad6c2ba58a696089fa9bab45c0b45f 100644 (file)
@@ -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;
 }
index 3f7d6b6aec1828182cd5b636ed9c6bc6c28f158a..a7c98ec39ef1a2f80205127fab8dc86c3b626082 100644 (file)
@@ -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 */
index aaa6974c7cfaa1b4fb1e727f95be5a443ceb15b5..ed8006d413da385a78b8c5416ecc121bffade96b 100644 (file)
@@ -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)
index 84b9799355fecef62cc00781467f84791b348361..4c2200bdb9566852e8858ca43bd754c25ba44592 100644 (file)
@@ -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));
+}
+
index 0ec74893ad1c5cd9e1f78e024f1eb3e510034e58..0f9aac6158272f7a9b867c9279fbf41bb0aeb7c3 100644 (file)
@@ -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