Ensure that the hash_table messages show useful information.
[oweals/opkg-lede.git] / libopkg / opkg_conf.c
index b6ca4a8ccf75340d6b47e706e10a8e97c5d72ced..4b2ad03bbb10498af65cdb2e367528d384bddebc 100644 (file)
@@ -50,7 +50,7 @@ static int set_and_load_pkg_src_list(opkg_conf_t *conf,
 static int set_and_load_pkg_dest_list(opkg_conf_t *conf,
                                      nv_pair_list_t *nv_pair_list, char * lists_dir);
 
-int opkg_init_options_array(const opkg_conf_t *conf, opkg_option_t **options)
+void opkg_init_options_array(const opkg_conf_t *conf, opkg_option_t **options)
 {
      opkg_option_t tmp[] = {
          { "cache", OPKG_OPT_TYPE_STRING, &conf->cache},
@@ -99,7 +99,6 @@ int opkg_init_options_array(const opkg_conf_t *conf, opkg_option_t **options)
 
      *options = xcalloc(1, sizeof(tmp));
      memcpy(*options, tmp, sizeof(tmp));
-     return 0;
 };
 
 static void opkg_conf_override_string(char **conf_str, char *arg_str) 
@@ -371,12 +370,6 @@ void opkg_conf_deinit(opkg_conf_t *conf)
      pkg_src_list_deinit(&conf->pkg_src_list);
      pkg_dest_list_deinit(&conf->pkg_dest_list);
      nv_pair_list_deinit(&conf->arch_list);
-     if (&conf->pkg_hash)
-                   pkg_hash_deinit(&conf->pkg_hash);
-     if (&conf->file_hash)
-                   hash_table_deinit(&conf->file_hash);
-     if (&conf->obs_file_hash)
-                   hash_table_deinit(&conf->obs_file_hash);
 
      opkg_conf_free_string(&conf->offline_root);
      opkg_conf_free_string(&conf->offline_root_path);
@@ -426,9 +419,15 @@ void opkg_conf_deinit(opkg_conf_t *conf)
               }
               opkg_message(conf, OPKG_DEBUG, "hash_table[%s] n_buckets=%d n_elements=%d max_conflicts=%d n_conflicts=%d\n", 
                            hash->name, hash->n_entries, hash->n_elements, c, n_conflicts);
-              hash_table_deinit(hash);
          }
      }
+
+     if (&conf->pkg_hash)
+                   pkg_hash_deinit(&conf->pkg_hash);
+     if (&conf->file_hash)
+                   hash_table_deinit(&conf->file_hash);
+     if (&conf->obs_file_hash)
+                   hash_table_deinit(&conf->obs_file_hash);
 }
 
 static int opkg_conf_set_default_dest(opkg_conf_t *conf,
@@ -520,8 +519,7 @@ static int opkg_conf_parse_file(opkg_conf_t *conf, const char *filename,
 #define regmatch_size 12
      regmatch_t regmatch[regmatch_size];
 
-     if (opkg_init_options_array(conf, &options)<0)
-        return ENOMEM;
+     opkg_init_options_array(conf, &options);
 
      if (file == NULL) {
          fprintf(stderr, "%s: failed to open %s: %s\n",