# HG changeset patch # User Matti Hamalainen # Date 1675253365 -7200 # Node ID 2ab2fece83ea86569f36a158ad98ff5d98e3898d # Parent 4bd82aca5e989d60f7050363fd9dea269ae40b3f Add th_llist_length_slow(). diff -r 4bd82aca5e98 -r 2ab2fece83ea th_datastruct.c --- a/th_datastruct.c Wed Feb 01 14:09:12 2023 +0200 +++ b/th_datastruct.c Wed Feb 01 14:09:25 2023 +0200 @@ -203,6 +203,17 @@ } +size_t th_llist_length_slow(const th_llist_t *list) +{ + th_llist_t *curr = list; + size_t i; + + for (i = 0; curr != NULL; curr = curr->next, i++); + + return i; +} + + ssize_t th_llist_position(const th_llist_t *list, const th_llist_t *node) { const th_llist_t *curr = list; diff -r 4bd82aca5e98 -r 2ab2fece83ea th_datastruct.h --- a/th_datastruct.h Wed Feb 01 14:09:12 2023 +0200 +++ b/th_datastruct.h Wed Feb 01 14:09:25 2023 +0200 @@ -41,6 +41,7 @@ th_llist_t * th_llist_get_nth(th_llist_t *list, const size_t n); size_t th_llist_length(const th_llist_t *list); +size_t th_llist_length_slow(const th_llist_t *list); ssize_t th_llist_position(const th_llist_t *list, const th_llist_t *node); void th_llist_reverse(th_llist_t **list);