Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2024 | ||
3 | ** my_strdup_word_array | ||
4 | ** File description: | ||
5 | ** Returns a duplication of a word array (array) | ||
6 | */ | ||
7 | /** | ||
8 | * @file my_strdup_word_array.c | ||
9 | * @brief The file containing the my_strdup_word_array function | ||
10 | * @author Nicolas TORO | ||
11 | */ | ||
12 | |||
13 | #include "my.h" | ||
14 | |||
15 | 2 | char **my_strdup_word_array(char **array) | |
16 | { | ||
17 | char **new_array; | ||
18 | 2 | int i = 0; | |
19 | |||
20 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (array == NULL) |
21 | 1 | return NULL; | |
22 | 1 | new_array = malloc(sizeof(char *) * (my_array_len((void **)array) + 1)); | |
23 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (; array[i] != NULL; i++) |
24 | 4 | new_array[i] = my_strdup(array[i]); | |
25 | 1 | new_array[i] = NULL; | |
26 | 1 | return new_array; | |
27 | } | ||
28 |