X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/8b4052ad6015aa9f54c9c824f28655f230d09d8d..24b8c863b154e1bee674597ffcd818d4d959c9a1:/ll.c diff --git a/ll.c b/ll.c index 3545a9c..018ea0d 100644 --- a/ll.c +++ b/ll.c @@ -28,6 +28,33 @@ struct ll *lladd(struct ll *curll, void *object) return new; } +struct ll *lladdend(struct ll *curll, void *object) +{ + struct ll *new; + struct ll *cur; + + if ((new = malloc(sizeof(struct ll))) == NULL) { + logthing(LOGTHING_ERROR, + "Couldn't allocate memory in lladdend()"); + return NULL; + } + + new->next = NULL; + new->object = object; + + if (curll != NULL) { + cur = curll; + while (cur->next != NULL) { + cur = cur->next; + } + cur->next = new; + } else { + curll = new; + } + + return curll; +} + struct ll *lldel(struct ll *curll, void *object, int (*objectcmp) (const void *object1, const void *object2)) {