More memory hygeine.
[disorder] / clients / disorder.c
index dac6c25..5f5ee4d 100644 (file)
@@ -175,13 +175,12 @@ static void cf_rescan(char attribute((unused)) **argv) {
 
 static void cf_somequeue(int (*fn)(disorder_client *c,
                                   struct queue_entry **qp)) {
-  struct queue_entry *q;
+  struct queue_entry *q, *qbase;
 
-  if(fn(getclient(), &q)) exit(EXIT_FAILURE);
-  while(q) {
+  if(fn(getclient(), &qbase)) exit(EXIT_FAILURE);
+  for(q = qbase; q; q = q->next)
     print_queue_entry(q);
-    q = q->next;
-  }
+  queue_free(qbase, 1);
 }
 
 static void cf_recent(char attribute((unused)) **argv) {
@@ -279,12 +278,13 @@ static void cf_unset(char **argv) {
 }
 
 static void cf_prefs(char **argv) {
-  struct kvp *k;
+  struct kvp *k, *base;
 
-  if(disorder_prefs(getclient(), argv[0], &k)) exit(EXIT_FAILURE);
-  for(; k; k = k->next)
+  if(disorder_prefs(getclient(), argv[0], &base)) exit(EXIT_FAILURE);
+  for(k = base; k; k = k->next)
     xprintf("%s = %s\n",
            nullcheck(utf82mb(k->name)), nullcheck(utf82mb(k->value)));
+  kvp_free(base);
 }
 
 static void cf_search(char **argv) {