diff th_datastruct.c @ 757:2ab2fece83ea

Add th_llist_length_slow().
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 01 Feb 2023 14:09:25 +0200
parents 4bd82aca5e98
children 72fb5ce9086a
line wrap: on
line diff
--- 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;