Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2023 | ||
3 | ** my_push_front | ||
4 | ** File description: | ||
5 | ** Adds a node at the beginning of a linked list | ||
6 | */ | ||
7 | |||
8 | #include "mylist.h" | ||
9 | |||
10 | 8 | void my_push_front(linked_list_t **begin, void *data, type_t type) | |
11 | { | ||
12 | 8 | linked_list_t *new = malloc(sizeof(linked_list_t)); | |
13 | |||
14 | 8 | new->prev = NULL; | |
15 | 8 | new->data = data; | |
16 | 8 | new->type = type; | |
17 | 8 | new->next = *begin; | |
18 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
|
8 | if (*begin != NULL) |
19 | 3 | (*begin)->prev = new; | |
20 | 8 | *begin = new; | |
21 | 8 | } | |
22 |