about summary refs log tree commit diff
path: root/Src/linklist.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/linklist.c')
-rw-r--r--Src/linklist.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/Src/linklist.c b/Src/linklist.c
index 9e70d1372..76c32a62d 100644
--- a/Src/linklist.c
+++ b/Src/linklist.c
@@ -220,3 +220,26 @@ rolllist(LinkList l, LinkNode nd)
     l->last->next = 0;
 }
 
+/**/
+LinkList
+newsizedlist(int size)
+{
+    LinkList list;
+    LinkNode node;
+
+    MUSTUSEHEAP("newsizedlist()");
+
+    list = (LinkList) zhalloc(sizeof(struct linklist) +
+			      (size * sizeof(struct linknode)));
+
+    list->first = (LinkNode) (list + 1);
+    for (node = list->first; size; size--, node++) {
+	node->last = node - 1;
+	node->next = node + 1;
+    }
+    list->last = node - 1;
+    list->first->last = (LinkNode) list;
+    node[-1].next = NULL;
+
+    return list;
+}