Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2023 | ||
3 | ** my_strdup | ||
4 | ** File description: | ||
5 | ** Returns a duplication of a string (src) | ||
6 | */ | ||
7 | |||
8 | #include "my.h" | ||
9 | |||
10 | 128 | char *my_strdup(char const *src) | |
11 | { | ||
12 | char *result; | ||
13 | 128 | int len_src = my_strlen(src); | |
14 | 128 | int i = 0; | |
15 | |||
16 | 128 | result = my_malloc(sizeof(char) * (len_src + 1), 1); | |
17 |
2/2✓ Branch 0 taken 985 times.
✓ Branch 1 taken 128 times.
|
1113 | for (; i < len_src; i++) { |
18 | 985 | result[i] = src[i]; | |
19 | } | ||
20 | 128 | result[i] = '\0'; | |
21 | 128 | return result; | |
22 | } | ||
23 |