about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-02-09 22:11:25 +0000
committerJames Booth <boothj5@gmail.com>2015-02-09 22:11:25 +0000
commit64774a947edf87f6acae07305861149f5194052b (patch)
tree75ad173244441c907a626547fdd7f9d2d2c47424 /src/ui
parent51ccb695804fc4174b59cd45b7008f13bddd4739 (diff)
parent5c9dd2802a6aefcaa67cbf03a65128b595b587c9 (diff)
downloadprofani-tty-64774a947edf87f6acae07305861149f5194052b.tar.gz
Merge branch 'master' into readline
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/window.c20
-rw-r--r--src/ui/windows.c12
2 files changed, 19 insertions, 13 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index bfef7946..585e0955 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -682,8 +682,6 @@ win_show_info(ProfWin *window, PContact contact)
     const char *name = p_contact_name(contact);
     const char *presence = p_contact_presence(contact);
     const char *sub = p_contact_subscription(contact);
-    GList *resources = p_contact_get_available_resources(contact);
-    GList *ordered_resources = NULL;
     GDateTime *last_activity = p_contact_last_activity(contact);
 
     theme_item_t presence_colour = theme_main_presence_attrs(presence);
@@ -719,20 +717,25 @@ win_show_info(ProfWin *window, PContact contact)
         g_date_time_unref(now);
     }
 
+    GList *resources = p_contact_get_available_resources(contact);
+    GList *ordered_resources = NULL;
     if (resources != NULL) {
         win_save_print(window, '-', NULL, 0, 0, "", "Resources:");
 
         // sort in order of availabiltiy
-        while (resources != NULL) {
-            Resource *resource = resources->data;
+        GList *curr = resources;
+        while (curr != NULL) {
+            Resource *resource = curr->data;
             ordered_resources = g_list_insert_sorted(ordered_resources,
                 resource, (GCompareFunc)resource_compare_availability);
-            resources = g_list_next(resources);
+            curr = g_list_next(curr);
         }
     }
+    g_list_free(resources);
 
-    while (ordered_resources != NULL) {
-        Resource *resource = ordered_resources->data;
+    GList *curr = ordered_resources;
+    while (curr != NULL) {
+        Resource *resource = curr->data;
         const char *resource_presence = string_from_resource_presence(resource->presence);
         theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
         win_save_vprint(window, '-', NULL, NO_EOL, presence_colour, "", "  %s (%d), %s", resource->name, resource->priority, resource_presence);
@@ -787,8 +790,9 @@ win_show_info(ProfWin *window, PContact contact)
             caps_destroy(caps);
         }
 
-        ordered_resources = g_list_next(ordered_resources);
+        curr = g_list_next(curr);
     }
+    g_list_free(ordered_resources);
 }
 
 void
diff --git a/src/ui/windows.c b/src/ui/windows.c
index 5ecada12..3132902f 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -132,6 +132,7 @@ wins_get_muc(const char * const roomjid)
         if (window->type == WIN_MUC) {
             ProfMucWin *mucwin = (ProfMucWin*)window;
             if (g_strcmp0(mucwin->roomjid, roomjid) == 0) {
+                g_list_free(values);
                 return mucwin;
             }
         }
@@ -153,6 +154,7 @@ wins_get_private(const char * const fulljid)
         if (window->type == WIN_PRIVATE) {
             ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
             if (g_strcmp0(privatewin->fulljid, fulljid) == 0) {
+                g_list_free(values);
                 return privatewin;
             }
         }
@@ -408,9 +410,9 @@ wins_new_xmlconsole(void)
 {
     GList *keys = g_hash_table_get_keys(windows);
     int result = get_next_available_win_num(keys);
+    g_list_free(keys);
     ProfWin *newwin = win_create_xmlconsole();
     g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
-    g_list_free(keys);
     return newwin;
 }
 
@@ -419,9 +421,9 @@ wins_new_chat(const char * const barejid)
 {
     GList *keys = g_hash_table_get_keys(windows);
     int result = get_next_available_win_num(keys);
+    g_list_free(keys);
     ProfWin *newwin = win_create_chat(barejid);
     g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
-    g_list_free(keys);
     return newwin;
 }
 
@@ -430,9 +432,9 @@ wins_new_muc(const char * const roomjid)
 {
     GList *keys = g_hash_table_get_keys(windows);
     int result = get_next_available_win_num(keys);
+    g_list_free(keys);
     ProfWin *newwin = win_create_muc(roomjid);
     g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
-    g_list_free(keys);
     return newwin;
 }
 
@@ -441,9 +443,9 @@ wins_new_muc_config(const char * const roomjid, DataForm *form)
 {
     GList *keys = g_hash_table_get_keys(windows);
     int result = get_next_available_win_num(keys);
+    g_list_free(keys);
     ProfWin *newwin = win_create_muc_config(roomjid, form);
     g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
-    g_list_free(keys);
     return newwin;
 }
 
@@ -452,9 +454,9 @@ wins_new_private(const char * const fulljid)
 {
     GList *keys = g_hash_table_get_keys(windows);
     int result = get_next_available_win_num(keys);
+    g_list_free(keys);
     ProfWin *newwin = win_create_private(fulljid);
     g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
-    g_list_free(keys);
     return newwin;
 }