only add pkg_vec_sort when needed
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Wed, 17 Dec 2008 00:27:16 +0000 (00:27 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Wed, 17 Dec 2008 00:27:16 +0000 (00:27 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@184 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/opkg_cmd.c
libopkg/pkg_hash.c

index af6c4b7c7f6861c37f227e5c7a538e971e6ee492..fae308527d18f927a2811feefb2d60f987ec4b7e 100644 (file)
@@ -711,6 +711,7 @@ static int opkg_list_cmd(opkg_conf_t *conf, int argc, char **argv)
      }
      available = pkg_vec_alloc();
      pkg_hash_fetch_available(&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 */
@@ -1439,6 +1440,7 @@ static int opkg_search_cmd(opkg_conf_t *conf, int argc, char **argv)
  
      installed = pkg_vec_alloc();
      pkg_hash_fetch_all_installed(&conf->pkg_hash, installed);
+     pkg_vec_sort(installed, pkg_compare_names);
 
      for (i=0; i < installed->len; i++) {
          pkg = installed->pkgs[i];
@@ -1458,9 +1460,6 @@ static int opkg_search_cmd(opkg_conf_t *conf, int argc, char **argv)
          pkg_free_installed_files(pkg);
      }
 
-     /* XXX: CLEANUP: It's not obvious from the name of
-       pkg_hash_fetch_all_installed that we need to call
-       pkg_vec_free to avoid a memory leak. */
      pkg_vec_free(installed);
 
      return 0;
index ed8006d413da385a78b8c5416ecc121bffade96b..35f65a32c5acf8178ce596e056f3e41d624f5741 100644 (file)
@@ -477,7 +477,6 @@ 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);
 }
 
 static void pkg_hash_fetch_all_installed_helper(const char *pkg_name, void *entry, void *data)
@@ -498,7 +497,6 @@ 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);
 }
 
 static void pkg_hash_dump_helper(const char *pkg_name, void *entry, void *data)