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