| 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 | * @file my_push_front.c | ||
| 9 | * @brief The file containing the my_push_front function | ||
| 10 | * @author Nicolas TORO | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include "mylist.h" | ||
| 14 | |||
| 15 | 14 | void my_push_front(node_t **begin, void *data, type_t type) | |
| 16 | { | ||
| 17 | 14 | node_t *new = malloc(sizeof(node_t)); | |
| 18 | |||
| 19 | 14 | new->prev = NULL; | |
| 20 | 14 | new->data = data; | |
| 21 | 14 | new->type = type; | |
| 22 | 14 | new->next = *begin; | |
| 23 | 2/2✓ Branch 0 taken 9 times. ✓ Branch 1 taken 5 times. | 14 | if (*begin != NULL) | 
| 24 | 9 | (*begin)->prev = new; | |
| 25 | 14 | *begin = new; | |
| 26 | 14 | } | |
| 27 |