tests
This commit is contained in:
@@ -13,7 +13,7 @@ struct list *list_append(struct list *l, int e)
|
||||
new_node->data = e;
|
||||
if(!l) return new_node;
|
||||
|
||||
while (tmp->next) tmp = tmp->next;
|
||||
while (tmp->next != NULL) tmp = tmp->next;
|
||||
tmp->next = new_node;
|
||||
return l;
|
||||
|
||||
@@ -21,17 +21,17 @@ struct list *list_append(struct list *l, int e)
|
||||
size_t list_count(struct list *l){
|
||||
|
||||
int nbr_nodes = 0;
|
||||
if (!l) return nbr_nodes;
|
||||
//if (!l) return nbr_nodes;
|
||||
|
||||
struct list *tmp = l;
|
||||
|
||||
//nbr_nodes ++;
|
||||
while(tmp->next != NULL) {
|
||||
while(tmp != NULL) {
|
||||
nbr_nodes ++;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
return nbr_nodes + 1;
|
||||
return nbr_nodes;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user