1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Fixed freeing lists

This commit is contained in:
James Booth 2014-11-13 01:01:41 +00:00
parent ada6f5a8b6
commit 0a7c16747b
2 changed files with 18 additions and 16 deletions

View File

@ -330,8 +330,19 @@ GList *
p_contact_get_available_resources(const PContact contact) p_contact_get_available_resources(const PContact contact)
{ {
assert(contact != NULL); assert(contact != NULL);
GList *resources = g_hash_table_get_values(contact->available_resources);
GList *ordered = NULL;
return g_hash_table_get_values(contact->available_resources); GList *curr_resource = resources;
while (curr_resource) {
Resource *resource = resources->data;
ordered = g_list_insert_sorted(ordered, resource, (GCompareFunc)resource_compare_availability);
curr_resource = g_list_next(curr_resource);
}
g_list_free(resources);
return ordered;
} }
gboolean gboolean

View File

@ -2835,19 +2835,9 @@ _ui_roster_contact(PContact contact)
if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) { if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) {
GList *resources = p_contact_get_available_resources(contact); GList *resources = p_contact_get_available_resources(contact);
GList *ordered_resources = NULL; GList *curr_resource = resources;
while (curr_resource) {
// sort in order of availabiltiy Resource *resource = curr_resource->data;
while (resources != NULL) {
Resource *resource = resources->data;
ordered_resources = g_list_insert_sorted(ordered_resources, resource, (GCompareFunc)resource_compare_availability);
resources = g_list_next(resources);
}
g_list_free(resources);
while (ordered_resources) {
Resource *resource = ordered_resources->data;
const char *resource_presence = string_from_resource_presence(resource->presence); const char *resource_presence = string_from_resource_presence(resource->presence);
int resource_presence_colour = win_presence_colour(resource_presence); int resource_presence_colour = win_presence_colour(resource_presence);
wattron(window->subwin, resource_presence_colour); wattron(window->subwin, resource_presence_colour);
@ -2859,9 +2849,9 @@ _ui_roster_contact(PContact contact)
wattroff(window->subwin, resource_presence_colour); wattroff(window->subwin, resource_presence_colour);
ordered_resources = g_list_next(ordered_resources); curr_resource = g_list_next(curr_resource);
} }
g_list_free(ordered_resources); g_list_free(resources);
} }
} }
} }
@ -2951,6 +2941,7 @@ _ui_roster(void)
_ui_roster_contacts_by_group(curr_group->data); _ui_roster_contacts_by_group(curr_group->data);
curr_group = g_slist_next(curr_group); curr_group = g_slist_next(curr_group);
} }
g_slist_free_full(groups, free);
_ui_roster_contacts_by_no_group(); _ui_roster_contacts_by_no_group();
} else { } else {
GSList *contacts = roster_get_contacts(); GSList *contacts = roster_get_contacts();