about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-02-10 20:30:50 +0000
committerJames Booth <boothj5@gmail.com>2015-02-10 20:30:50 +0000
commite565812d09cc3b257792cbafbb7ee1aa37d238c3 (patch)
tree1b6373b51c8489118e63d24333f3c6036dcdd9c0
parent22b92c751445b14e35b9b0e94479f79d2434c0a5 (diff)
downloadprofani-tty-e565812d09cc3b257792cbafbb7ee1aa37d238c3.tar.gz
Free roster list
-rw-r--r--src/command/commands.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index af5c8cc8..3c1a0980 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1046,12 +1046,13 @@ _who_roster(gchar **args, struct cmd_help_t help)
     } else if (strcmp("available", presence) == 0) {
         GSList *filtered = NULL;
 
-        while (list != NULL) {
-            PContact contact = list->data;
+        GSList *curr = list;
+        while (curr != NULL) {
+            PContact contact = curr->data;
             if (p_contact_is_available(contact)) {
                 filtered = g_slist_append(filtered, contact);
             }
-            list = g_slist_next(list);
+            curr = g_slist_next(curr);
         }
 
         if (group != NULL) {
@@ -1075,12 +1076,13 @@ _who_roster(gchar **args, struct cmd_help_t help)
     } else if (strcmp("unavailable", presence) == 0) {
         GSList *filtered = NULL;
 
-        while (list != NULL) {
-            PContact contact = list->data;
+        GSList *curr = list;
+        while (curr != NULL) {
+            PContact contact = curr->data;
             if (!p_contact_is_available(contact)) {
                 filtered = g_slist_append(filtered, contact);
             }
-            list = g_slist_next(list);
+            curr = g_slist_next(curr);
         }
 
         if (group != NULL) {
@@ -1104,12 +1106,13 @@ _who_roster(gchar **args, struct cmd_help_t help)
     } else if (strcmp("online", presence) == 0) {
         GSList *filtered = NULL;
 
-        while (list != NULL) {
-            PContact contact = list->data;
+        GSList *curr = list;
+        while (curr != NULL) {
+            PContact contact = curr->data;
             if (p_contact_has_available_resource(contact)) {
                 filtered = g_slist_append(filtered, contact);
             }
-            list = g_slist_next(list);
+            curr = g_slist_next(curr);
         }
 
         if (group != NULL) {
@@ -1133,12 +1136,13 @@ _who_roster(gchar **args, struct cmd_help_t help)
     } else if (strcmp("offline", presence) == 0) {
         GSList *filtered = NULL;
 
-        while (list != NULL) {
-            PContact contact = list->data;
+        GSList *curr = list;
+        while (curr != NULL) {
+            PContact contact = curr->data;
             if (!p_contact_has_available_resource(contact)) {
                 filtered = g_slist_append(filtered, contact);
             }
-            list = g_slist_next(list);
+            curr = g_slist_next(curr);
         }
 
         if (group != NULL) {
@@ -1162,12 +1166,13 @@ _who_roster(gchar **args, struct cmd_help_t help)
     } else {
         GSList *filtered = NULL;
 
-        while (list != NULL) {
-            PContact contact = list->data;
+        GSList *curr = list;
+        while (curr != NULL) {
+            PContact contact = curr->data;
             if (strcmp(p_contact_presence(contact), presence) == 0) {
                 filtered = g_slist_append(filtered, contact);
             }
-            list = g_slist_next(list);
+            curr = g_slist_next(curr);
         }
 
         if (group != NULL) {
@@ -1188,7 +1193,6 @@ _who_roster(gchar **args, struct cmd_help_t help)
         g_slist_free(filtered);
     }
 
-    list = g_slist_nth(list, 0);
     g_slist_free(list);
 }