4
static List freenodes; /* free list nodes */
6
/* append - append x to list, return new list */
7
List append(void *x, List list) {
10
if ((new = freenodes) != NULL)
11
freenodes = freenodes->link;
15
new->link = list->link;
23
/* length - # elements in list */
24
int length(List list) {
31
while ((lp = lp->link) != list);
36
/* ltov - convert list to an NULL-terminated vector allocated in arena */
37
void *ltov(List *list, unsigned arena) {
39
void **array = newarray(length(*list) + 1, sizeof array[0], arena);
46
} while (lp != *list);
49
(*list)->link = freenodes;