dev #1

Merged
lucas merged 3 commits from dev into master 2026-04-02 17:37:29 +00:00
2 changed files with 17 additions and 11 deletions
Showing only changes of commit 3d0dd9e993 - Show all commits
@@ -5,6 +5,15 @@
struct list *list_append(struct list *l, int e)
{
struct list *new_node = malloc(sizeof(struct list));
if(!new_node) return NULL;
new_node->data = e;
new_node->next = l;
return new_node;
/*
struct list *tmp = l;
struct list *new_node = calloc(1, sizeof(struct list));
@@ -16,7 +25,7 @@ struct list *list_append(struct list *l, int e)
while (tmp->next != NULL) tmp = tmp->next;
tmp->next = new_node;
return l;
*/
}
size_t list_count(struct list *l){
@@ -162,26 +171,23 @@ void list_print(struct list *l){
}
printf("\n");
}
/*
int main(void)
{
struct list *l = NULL;
l = list_append(l, 42); // l = [42] -> NULL
list_print(l);
l = list_append(l, 7); // l = [7] -> [42] -> NULL
list_print(l);
l = list_append(l, 3);
l = list_append(l, 2);
l = list_append(l, 1);
// l = [1] -> [2] -> [3]
list_insert(&l, 1, 99); // l = [1] -> [99] -> [2] -> [3], and list_insert returns 0
list_insert(&l, 9, 99); // list unchanged, returns 1
list_print(l);
list_count(NULL); // 0
printf("count : %li\n",list_count(l)); // 3
list_print(l);
list_destroy(l);
return 0;
}
*/
Binary file not shown.