GCC Code Coverage Report


Directory: ./
File: lib/mylist/my_push_back.c
Date: 2024-05-07 14:54:03
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 12314 void my_push_back(node_t **begin, void *data, type_t type)
16 {
17 12314 node_t *new = malloc(sizeof(node_t));
18 12314 node_t *tmp = *begin;
19
20 12314 new->data = data;
21 12314 new->type = type;
22 12314 new->next = NULL;
23
2/2
✓ Branch 0 taken 4186 times.
✓ Branch 1 taken 8128 times.
12314 if (*begin == NULL) {
24 4186 new->prev = NULL;
25 4186 *begin = new;
26 4186 return;
27 }
28
2/2
✓ Branch 0 taken 6617446 times.
✓ Branch 1 taken 8128 times.
6625574 while (tmp->next != NULL)
29 6617446 tmp = tmp->next;
30 8128 tmp->next = new;
31 8128 new->prev = tmp;
32 }
33