GCC Code Coverage Report


Directory: ./
File: lib/mylist/my_push_back_circled.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 15 15 100.0%
Functions: 1 1 100.0%
Branches: 6 6 100.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_push_back_circled
4 ** File description:
5 ** Adds a node at the end of a linked list
6 */
7 /**
8 * @file my_push_back_circled.c
9 * @brief The file containing the my_push_back_circled function
10 * @author Gianni TUERO
11 */
12
13 #include "mylist.h"
14
15 216965 void my_push_back_circled(node_t **begin, void *data, type_t type)
16 {
17 216965 node_t *new = malloc(sizeof(node_t));
18 216965 node_t *tmp = *begin;
19
20 216965 new->data = data;
21 216965 new->type = type;
22
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 216595 times.
216965 if (*begin == NULL) {
23 370 new->prev = NULL;
24 370 new->next = NULL;
25 370 *begin = new;
26 370 return;
27 }
28
4/4
✓ Branch 0 taken 84537293 times.
✓ Branch 1 taken 370 times.
✓ Branch 2 taken 84321068 times.
✓ Branch 3 taken 216225 times.
84537663 for (; tmp->next != NULL && tmp->next != *begin; tmp = tmp->next);
29 216595 tmp->next = new;
30 216595 new->prev = tmp;
31 216595 new->next = *begin;
32 216595 (*begin)->prev = new;
33 }
34