GCC Code Coverage Report


Directory: ./
File: lib/mylist/my_push_back.c
Date: 2024-06-05 00:34:38
Exec Total Coverage
Lines: 14 14 100.0%
Functions: 1 1 100.0%
Branches: 4 4 100.0%

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