GCC Code Coverage Report


Directory: ./
File: lib/mymemory/my_malloc.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 10 10 100.0%
Functions: 1 1 100.0%
Branches: 8 8 100.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** my_malloc
4 ** File description:
5 ** Free allocated memory (type 0) or allocates memory (type 1)
6 ** of a certain size (size)
7 */
8 /**
9 * @file my_malloc.c
10 * @brief The file containing the my_malloc function
11 * @author Nicolas TORO
12 */
13
14 #include "mymemory.h"
15
16 32514 void *my_malloc(size_t size, int type)
17 {
18 static node_t *list = NULL;
19 void *ptr;
20
21
4/4
✓ Branch 0 taken 31612 times.
✓ Branch 1 taken 902 times.
✓ Branch 2 taken 31611 times.
✓ Branch 3 taken 1 times.
32514 if (type == 1 && size > 0) {
22 31611 ptr = malloc(size);
23
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 31610 times.
31611 if (ptr == NULL)
24 1 return NULL;
25 31610 my_push_front(&list, ptr, VOID);
26 31610 return ptr;
27 }
28
2/2
✓ Branch 0 taken 902 times.
✓ Branch 1 taken 1 times.
903 if (type == 0)
29 902 my_delete_list(&list);
30 903 return NULL;
31 }
32