wm: glendy

Download patch

ref: d3b4fc2296c0f05e80d31bcb596bffdfe297da0b
parent: f5dca8e8a17fea2b08c8041fa85610b0b73afff3
author: mkf <mkf@cloud9p.org>
date: Thu Jun 6 16:50:13 EDT 2024

fix qadd

--- a/util.c
+++ b/util.c
@@ -149,22 +149,21 @@
 
 	dprint("llappend(%p, %p)\n", first, data);
 
-
-	for(last = first; 
-	last->next != nil  && last != last->next; 
-	last = last->next)
-		;
 	
 	/* workaround for first entry */	
 	if(first->data == nil)
 		temp = first;
 	else
+	{
+		for(last = first;
+		last->next != nil  && last != last->next;
+		last = last->next)
+			;
 		temp = llnew();
-	
-	temp->data = data;
-
-	if(last != nil)
 		last->next = temp;
+	}
+
+	temp->data = data;
 }
 
 List*
@@ -202,7 +201,7 @@
 	q->len++;
 	if(q->head == nil || q->tail == nil)
 	{
-		dprint("qadd(): q->head == nil && q->tail == nil\n");
+		dprint("qadd(): q->head == nil || q->tail == nil\n");
 		q->head = llnew();
 		q->head->data = data;
 		q->tail = q->head;
@@ -209,9 +208,9 @@
 	}
 	else
 	{
-		dprint("qadd(): q->head != nil || q->tail != nil\n");
-		llappend(q->first, data);
-		q->tail = q->tail->next;
+		dprint("qadd(): q->head != nil && q->tail != nil\n");
+		llappend(q->head, data);	
+		q->tail = (q->tail->next == nil) ? q->tail : q->tail->next;
 	}
 }