Have a routine to iterate over the remote host list.
authorGuy Harris <guy@alum.mit.edu>
Tue, 21 Feb 2017 02:31:15 +0000 (18:31 -0800)
committerGuy Harris <guy@alum.mit.edu>
Tue, 21 Feb 2017 02:31:27 +0000 (02:31 +0000)
Have a routine that iterates over the remote host list if it exists.

Remove the routine to get the remote host list; all accesses should be
through functions in ui/remote.c.

Change-Id: Idddceba76b50ce85ef8557e132d7552191c2fddc
Reviewed-on: https://code.wireshark.org/review/20217
Reviewed-by: Guy Harris <guy@alum.mit.edu>
ui/gtk/capture_dlg.c
ui/qt/remote_capture_dialog.cpp
ui/recent.c
ui/recent.h

index 41c4313fe9c54b0c86af6e5aa1e533677155d6d4..efc0bccbd803288e5ef377a32a2e2c1aa7764376 100644 (file)
@@ -1162,10 +1162,9 @@ iftype_combo_box_new(void)
 
   iftype_cbx = gtk_combo_box_text_new_with_entry();
 
-  ht = get_remote_host_list();
-  if (g_hash_table_size (ht) > 0) {
+  if (recent_get_remote_host_list_size() > 0) {
     /* Add remote hosts */
-    g_hash_table_foreach (ht, iftype_combo_box_add_remote_host, iftype_cbx);
+    remote_host_list_foreach (iftype_combo_box_add_remote_host, iftype_cbx);
     iftype_combo_box_add_remote_separators (iftype_cbx);
   }
 
index 98cc35ed1064bfb2fcf850d71dce37a88072ef97..7ec8a2f190a2c60c30b9791fc38069cd82e3c4b2 100644 (file)
@@ -82,11 +82,13 @@ static void fillBox(gpointer key, gpointer, gpointer user_data)
 
 void RemoteCaptureDialog::fillComboBox()
 {
-    GHashTable *ht = get_remote_host_list();
+    int remote_host_list_size;
+
     ui->hostCombo->addItem(QString(""));
-    if (recent_get_remote_host_list_size() > 0) {
-        g_hash_table_foreach(ht, fillBox, ui->hostCombo);
-        ui->hostCombo->insertSeparator(g_hash_table_size(ht)+1);
+    remote_host_list_size = recent_get_remote_host_list_size();
+    if (remote_host_list_size > 0) {
+        remote_host_list_foreach(fillBox, ui->hostCombo);
+        ui->hostCombo->insertSeparator(remote_host_list_size+1);
         ui->hostCombo->addItem(QString(tr("Clear list")));
     }
 }
index 01204f5d72fac05e0e5071b2259b6606a9d9d83c..3408cd84058eeb1c78d35fa762566f05d7b66c49 100644 (file)
@@ -412,9 +412,11 @@ free_remote_host (gpointer key _U_, gpointer value, gpointer user _U_)
   return TRUE;
 }
 
-GHashTable *get_remote_host_list(void)
+void
+remote_host_list_foreach(GHFunc func, gpointer user_data)
 {
-  return remote_host_list;
+  if (remote_host_list != NULL)
+    g_hash_table_foreach(remote_host_list, func, user_data);
 }
 
 static void
index 20b4701262017a600b655cc89fc0eebe96cebb5f..e027c6ba574fd7bccf58b242799e7a4be30c99cc 100644 (file)
@@ -225,11 +225,13 @@ extern struct remote_host *recent_get_remote_host(const gchar *host);
 extern int recent_get_remote_host_list_size(void);
 
 /**
- * Get the pointer of the remote_host_list.
+ * Iterate over all items in the remote_host_list, calling a
+ * function for each member
  *
- * @return Pointer to the hash table
+ * @param func Function to be called
+ * @param user_data Argument to pass as user data to the function
  */
-extern GHashTable *get_remote_host_list(void);
+extern void remote_host_list_foreach(GHFunc func, gpointer user_data);
 
 /**
  * Free all entries of the remote_host_list.