2 * ll.c - various things of used for dealing with linked lists.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2000-2002 Project Purple
15 struct ll *lladd(struct ll *curll, void *object)
19 if ((new = malloc(sizeof(struct ll))) == NULL) {
21 printf("Got NULL in lladd()\n");
31 struct ll *lldel(struct ll *curll, void *object,
32 int (*objectcmp) (const void *object1, const void *object2))
34 struct ll *cur = NULL;
35 struct ll *old = NULL;
37 assert(objectcmp != NULL);
42 } else if (!(*objectcmp)(cur->object, object)) {
48 while (cur->next != NULL) {
49 if (!(*objectcmp)(cur->next->object, object)) {
51 cur->next = cur->next->next;
59 struct ll *llfind(struct ll *curll, void *object,
60 int (*objectcmp) (const void *object1, const void *object2))
64 assert(objectcmp != NULL);
67 while (cur != NULL && (*objectcmp)(cur->object, object)) {
73 unsigned long llsize(struct ll *curll)
75 unsigned long count = 0;
77 while (curll != NULL) {