Save scan results on dhcpcd events.
authorRoy Marples <roy@marples.name>
Tue, 3 Feb 2009 10:33:58 +0000 (10:33 +0000)
committerRoy Marples <roy@marples.name>
Tue, 3 Feb 2009 10:33:58 +0000 (10:33 +0000)
main.c

diff --git a/main.c b/main.c
index 0bb38a77b0bcc60d10faedd74161dcf3bbaa8e4e..080b7708fe8daa8d3159f0c1a950e3f58ad9f7b0 100644 (file)
--- a/main.c
+++ b/main.c
@@ -92,6 +92,15 @@ find_if_msg(const char *iface)
 }
 
 static void
+free_if_ap(struct if_ap *ifa)
+{
+       g_free(ifa->bssid);
+       g_free(ifa->flags);
+       g_free(ifa->ssid);
+       g_free(ifa);
+}
+
+static void
 free_if_msg(struct if_msg *ifm)
 {
        GSList *gl;
@@ -100,21 +109,12 @@ free_if_msg(struct if_msg *ifm)
        g_free(ifm->reason);
        g_free(ifm->ssid);
        for (gl = ifm->scan_results; gl; gl = gl->next)
-               g_free(gl->data);
+               free_if_ap((struct if_ap *)gl->data);
        g_slist_free(ifm->scan_results);
        g_free(ifm);
 }
 
 static void
-free_if_ap(struct if_ap *ifa)
-{
-       g_free(ifa->bssid);
-       g_free(ifa->flags);
-       g_free(ifa->ssid);
-       g_free(ifa);
-}
-
-static void
 error_exit(const char *msg, GError *error)
 {
        GtkWidget *dialog;
@@ -465,6 +465,8 @@ dhcpcd_event(_unused DBusGProxy *proxy, GHashTable *config, _unused void *data)
        for (gl = interfaces; gl; gl = gl->next) {
                ifp = (struct if_msg *)gl->data;
                if (g_strcmp0(ifp->name, ifm->name) == 0) {
+                       ifm->scan_results = ifp->scan_results;
+                       ifp->scan_results = NULL;
                        free_if_msg(ifp);
                        if (rem)
                                interfaces = g_list_delete_link(interfaces, gl);