aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-07-25 23:28:04 +0100
committerJames Booth <boothj5@gmail.com>2016-07-25 23:28:04 +0100
commit8602ede65e2a4ef0edfa3a0b4b9c67c4158f15bb (patch)
treee51a5391b0b00df1fbe3a173724d61d1042107fa /src
parent6777919d96d77c5c1b08ad5ddd48ed2e4b15c87c (diff)
downloadprofani-tty-8602ede65e2a4ef0edfa3a0b4b9c67c4158f15bb.tar.gz
Tidy rosterwin memory handling
Diffstat (limited to 'src')
-rw-r--r--src/ui/rosterwin.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c
index 690677cd..933d1a72 100644
--- a/src/ui/rosterwin.c
+++ b/src/ui/rosterwin.c
@@ -102,6 +102,7 @@ rosterwin_roster(void)
} else {
GList *rooms = muc_rooms();
_rosterwin_rooms(layout, "Rooms", rooms);
+ g_list_free(rooms);
}
prefs_free_string(roomsbypref);
@@ -162,6 +163,7 @@ rosterwin_roster(void)
} else {
GList *rooms = muc_rooms();
_rosterwin_rooms(layout, "Rooms", rooms);
+ g_list_free(rooms);
}
prefs_free_string(roomsbypref);
@@ -660,7 +662,6 @@ _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms)
}
curr_room = g_list_next(curr_room);
}
- g_list_free(rooms);
// if there are active rooms, or if we want to show empty groups
if (rooms_sorted || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
@@ -679,15 +680,19 @@ _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms)
static void
_rosterwin_rooms_by_service(ProfLayoutSplit *layout)
{
- GList *curr_room = muc_rooms();
+ GList *rooms = muc_rooms();
+ GList *curr = rooms;
GList *services = NULL;
- while (curr_room) {
- char *roomjid = curr_room->data;
+ while (curr) {
+ char *roomjid = curr->data;
Jid *jidp = jid_create(roomjid);
+
if (!g_list_find_custom(services, jidp->domainpart, (GCompareFunc)g_strcmp0)) {
services = g_list_insert_sorted(services, strdup(jidp->domainpart), (GCompareFunc)g_strcmp0);
}
- curr_room = g_list_next(curr_room);
+
+ jid_destroy(jidp);
+ curr = g_list_next(curr);
}
GList *curr_service = services;
@@ -695,22 +700,27 @@ _rosterwin_rooms_by_service(ProfLayoutSplit *layout)
char *service = curr_service->data;
GList *filtered_rooms = NULL;
- curr_room = muc_rooms();
- while (curr_room) {
- char *roomjid = curr_room->data;
+ curr = rooms;
+ while (curr) {
+ char *roomjid = curr->data;
Jid *jidp = jid_create(roomjid);
if (g_strcmp0(curr_service->data, jidp->domainpart) == 0) {
- filtered_rooms = g_list_append(filtered_rooms, jidp->barejid);
+ filtered_rooms = g_list_append(filtered_rooms, strdup(jidp->barejid));
}
- curr_room = g_list_next(curr_room);
+ jid_destroy(jidp);
+ curr = g_list_next(curr);
}
_rosterwin_rooms(layout, service, filtered_rooms);
+ g_list_free_full(filtered_rooms, free);
curr_service = g_list_next(curr_service);
}
+
+ g_list_free(rooms);
+ g_list_free_full(services, free);
}
static void