| 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 | 34523 | void my_push_front(node_t **begin, void *data, type_t type) | |
| 16 | { | ||
| 17 | 34523 | node_t *new = malloc(sizeof(node_t)); | |
| 18 | |||
| 19 | 34523 | new->prev = NULL; | |
| 20 | 34523 | new->data = data; | |
| 21 | 34523 | new->type = type; | |
| 22 | 34523 | new->next = *begin; | |
| 23 |
2/2✓ Branch 0 taken 33749 times.
✓ Branch 1 taken 774 times.
|
34523 | if (*begin != NULL) |
| 24 | 33749 | (*begin)->prev = new; | |
| 25 | 34523 | *begin = new; | |
| 26 | 34523 | } | |
| 27 |