aboutsummaryrefslogtreecommitdiff
path: root/Src/replicant/nu/nodelist.c
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/replicant/nu/nodelist.c
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/replicant/nu/nodelist.c')
-rw-r--r--Src/replicant/nu/nodelist.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/Src/replicant/nu/nodelist.c b/Src/replicant/nu/nodelist.c
new file mode 100644
index 00000000..f1c21ea4
--- /dev/null
+++ b/Src/replicant/nu/nodelist.c
@@ -0,0 +1,71 @@
+#include "nodelist.h"
+
+void nodelist_init(nodelist_t nodelist)
+{
+ nodelist->head=0;
+ nodelist->tail=0;
+}
+
+void nodelist_push_back(nodelist_t nodelist, queue_node_t *item)
+{
+ if (!nodelist->head)
+ {
+ nodelist->head=item;
+ nodelist->tail=item;
+ }
+ else
+ {
+ nodelist->tail->Next=item;
+ nodelist->tail=item;
+ }
+ item->Next = 0;
+}
+
+void nodelist_push_front(nodelist_t nodelist, queue_node_t *item)
+{
+ if (!nodelist->head)
+ {
+ nodelist->head=item;
+ nodelist->tail=item;
+ item->Next=0;
+ }
+ else
+ {
+ item->Next = nodelist->head;
+ nodelist->head = item;
+ }
+}
+
+queue_node_t *nodelist_pop_front(nodelist_t nodelist)
+{
+ queue_node_t *ret;
+ if (!nodelist->head)
+ return 0;
+
+ ret = nodelist->head;
+ nodelist->head = nodelist->head->Next;
+ ret->Next = 0; // so we don't confuse anyone
+
+ if (ret == nodelist->tail)
+ {
+ nodelist->tail = 0;
+ }
+ return ret;
+}
+
+void nodelist_push_back_list(nodelist_t nodelist, queue_node_t *item)
+{
+ if (!nodelist->head)
+ {
+ nodelist->head=item;
+ }
+ else
+ {
+ nodelist->tail->Next=item;
+ }
+
+ while (item->Next)
+ item = item->Next;
+
+ nodelist->tail = item;
+}