TP 9 exo2: Simplify the return value handling in the list counting
[TD_C.git] / TP_9 / exo2 / clist.c
index db081179bae025aa5d7ce1e9fd14e00d266c28e2..2857042028966a52133304c9bd73d23534b8c22b 100644 (file)
@@ -32,9 +32,10 @@ link_t* list_prepend(link_t* head, int value) {
 }
 
 unsigned list_count(link_t* head) {
-    int count = 1;
+    int count = 0;
     
-    if (head == NULL) { return 0; }
+    if (head == NULL) { return count; }
+    count = 1;
     while (head->next != NULL) {
         ++count;
         head = head->next;