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 | 1949 | char **my_malloc_strdup_word_array(char **array) | |
16 | { | ||
17 | char **new_array; | ||
18 | 1949 | int i = 0; | |
19 | |||
20 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1948 times.
|
1949 | if (array == NULL) |
21 | 1 | return (NULL); | |
22 | 1948 | new_array = my_malloc(sizeof(char *) * | |
23 | 1948 | (my_array_len((void **)array) + 1), 1); | |
24 |
2/2✓ Branch 0 taken 17477 times.
✓ Branch 1 taken 1948 times.
|
19425 | for (; array[i] != NULL; i++) |
25 | 17477 | new_array[i] = my_malloc_strdup(array[i]); | |
26 | 1948 | new_array[i] = NULL; | |
27 | 1948 | return new_array; | |
28 | } | ||
29 |