Lines Matching refs:list

73  * Traversing forward through a list uses an iterator-style paradigm.
74 * for (LinkNode node = firstnode(list); node; incnode(node)) {
79 * for (LinkNode node = lastnode(list); node != &list->node; decnode(node)) {
86 * while (node && node != &list->node) {
87 * // If both incnode(list) and decnode(list) are used, and it's
88 * // unknown at which end of the list traversal will stop.
99 /* Get an empty linked list header */
105 LinkList list;
107 list = (LinkList) zhalloc(sizeof *list);
108 list->list.first = NULL;
109 list->list.last = &list->node;
110 list->list.flags = 0;
111 return list;
118 LinkList list;
120 list = (LinkList) zalloc(sizeof *list);
121 list->list.first = NULL;
122 list->list.last = &list->node;
123 list->list.flags = 0;
124 return list;
127 /* Insert a node in a linked list after a given node */
131 insertlinknode(LinkList list, LinkNode node, void *dat)
143 list->list.last = new;
149 zinsertlinknode(LinkList list, LinkNode node, void *dat)
161 list->list.last = new;
165 /* Insert an already-existing node into a linked list after a given node */
169 uinsertlinknode(LinkList list, LinkNode node, LinkNode new)
178 list->list.last = new;
182 /* Insert a list in another list */
194 l->list.last->next = nx;
195 l->list.first->prev = where;
199 x->list.last = lastnode(l);
202 /* Pop the top node off a linked list and free it. */
206 getlinknode(LinkList list)
211 if (!(node = firstnode(list)))
214 list->list.first = node->next;
216 node->next->prev = &list->node;
218 list->list.last = &list->node;
223 /* Pop the top node off a linked list without freeing it. */
227 ugetnode(LinkList list)
232 if (!(node = firstnode(list)))
235 list->list.first = node->next;
237 node->next->prev = &list->node;
239 list->list.last = &list->node;
243 /* Remove a node from a linked list */
247 remnode(LinkList list, LinkNode nd)
255 list->list.last = nd->prev;
262 /* Remove a node from a linked list without freeing */
266 uremnode(LinkList list, LinkNode nd)
274 list->list.last = nd->prev;
279 /* Free a linked list */
283 freelinklist(LinkList list, FreeFunc freefunc)
287 for (node = firstnode(list); node; node = next) {
293 zfree(list, sizeof *list);
296 /* Count the number of nodes in a linked list */
300 countlinknodes(LinkList list)
305 for (nd = firstnode(list); nd; incnode(nd), ct++);
315 l->list.last->next = firstnode(l);
316 l->list.first->prev = lastnode(l);
317 l->list.first = nd;
318 l->list.last = nd->prev;
320 l->list.last->next = 0;
329 LinkList list;
332 list = (LinkList) zhalloc(sizeof *list + (size * sizeof *node));
334 list->list.first = &list[1].node;
335 for (node = firstnode(list); size; size--, node++) {
339 list->list.last = node - 1;
340 list->list.first->prev = &list->node;
343 return list;
353 linknodebydatum(LinkList list, void *dat)
357 for (node = firstnode(list); node; incnode(node))
370 linknodebystring(LinkList list, char *dat)
374 for (node = firstnode(list); node; incnode(node))
382 * Convert a linked list whose data elements are strings to
384 * array are the same elements as the linked list data if copy is
390 hlinklist2array(LinkList list, int copy)
392 int l = countlinknodes(list);
396 for (n = firstnode(list), p = ret; n; incnode(n), p++) {
407 * Convert a linked list whose data elements are strings to
414 zlinklist2array(LinkList list)
416 int l = countlinknodes(list);
420 for (n = firstnode(list), p = ret; n; incnode(n), p++) {