ref: 3d813f4ec3edebcbe4a60083e9e8bebefc7d7267
parent: 65555c300f5930a49fcff6fc1ff05f993c6ae4c5
author: mkf <mkf@cloud9p.org>
date: Thu Jun 6 15:44:47 EDT 2024
util.c: fix buggy workaround for lladd on first element, (also log better)
--- a/util.c
+++ b/util.c
@@ -125,11 +125,11 @@
dprint("lladd(%p, %p)\n", last, data);
if(last->next != nil)
+ {
+ dprint("lladd(): last->next != nil\n");
return 0;
+ }
- /* first node? */
- if(last->data == nil)
- last->data = data;
else
{
dprint("lladd(): adding a new entry\n");
@@ -193,15 +193,6 @@
}
/* quene */
-/*
-void
-qadd(Quene *q, void *data)
-{
- q->len++;
- lladd(q->tail, data);
- q->tail = q->tail->next;
-}
-*/
void
qadd(Quene *q, void *data)
@@ -209,9 +200,9 @@
dprint("qadd(%p, %p)\n", q, data);
q->len++;
- if(q->head == nil && q->tail == nil)
+ if(q->head == nil || q->tail == nil)
{
- dprint("qadd(): q->head == nil || q->tail == nil");
+ dprint("qadd(): q->head == nil && q->tail == nil\n");
q->head = llnew();
q->head->data = data;
q->tail = q->head;
@@ -218,7 +209,7 @@
}
else
{
- dprint("qadd(): q->head != nil || q->tail != nil");
+ dprint("qadd(): q->head != nil || q->tail != nil\n");
lladd(q->tail, data);
q->tail = q->tail->next;
}
@@ -249,8 +240,10 @@
qnext(Quene *q)
{
List *tmp;
+
+ dprint("qnext(%p)\n", q);
if(q->head == nil)
- return;
+ return;
tmp = q->head;
q->head = q->head->next;