GCC Code Coverage Report


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

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_malloc_strdup
4 ** File description:
5 ** Returns a duplication of a string (src) with my_malloc
6 */
7 /**
8 * @file my_malloc_strdup.c
9 * @brief The file containing the my_malloc_strdup function
10 * @author Nicolas TORO
11 */
12
13 #include "mymemory.h"
14
15 28909 char *my_malloc_strdup(char const *src)
16 {
17 char *result;
18 28909 int len_src = my_strlen(src);
19 28909 int i = 0;
20
21
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 28908 times.
28909 if (src == NULL)
22 1 return NULL;
23 28908 result = my_malloc(sizeof(char) * (len_src + 1), 1);
24
2/2
✓ Branch 0 taken 646393 times.
✓ Branch 1 taken 28908 times.
675301 for (i = 0; i < len_src; i++)
25 646393 result[i] = src[i];
26 28908 result[i] = '\0';
27 28908 return result;
28 }
29