]> git.lizzy.rs Git - dragonstd.git/commitdiff
Add list_ppd
authorElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 4 Apr 2022 11:36:36 +0000 (13:36 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 4 Apr 2022 11:36:36 +0000 (13:36 +0200)
list.c
list.h

diff --git a/list.c b/list.c
index d8416d941b6cbd32d87cacd18e70bc21d6a5f09c..f7b3803fbacfb822c78b76c890a1ce198cd40ace 100644 (file)
--- a/list.c
+++ b/list.c
@@ -18,6 +18,13 @@ void list_apd(List *list, void *dat)
        list_nmk(list, list->end, dat);
 }
 
+void list_ppd(List *list, void *dat)
+{
+       ListNode *fst = list->fst;
+       list_nmk(list, &list->fst, dat);
+       list->fst->nxt = fst;
+}
+
 ListNode **list_nfd(List *list, void *key, Comparator cmp)
 {
        ListNode **node;
diff --git a/list.h b/list.h
index eb8f97b7ec8b109aa576d85f3b4b5eca4032632c..d57f3781866135c6955301657bc8454e999e9fd8 100644 (file)
--- a/list.h
+++ b/list.h
@@ -61,6 +61,11 @@ void list_apd(List *list, void *dat);
        Append an element at the end of the list.
 */
 
+void list_ppd(List *list, void *dat);
+/*
+       Prepend an element at the start of the list.
+*/
+
 ListNode **list_nfd(List *list, void *key, Comparator cmp);
 /*
        Find the location of the first node matching key.