Coverage report for server


src/
File: src/utils/arrays.c
Date: 2024-06-25 10:57:05
Lines:
5/12
41.7%
Functions:
1/3
33.3%
Branches:
3/12
25.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** zappy
4 ** File description:
5 ** arrays.c
6 */
7
8 #include "utils.h"
9
10 size_t array_len(void **array)
11 {
12 size_t len = 0;
13
14 if (!array)
15 return 0;
16 for (; array[len]; len++);
17 return len;
18 }
19
20 2 void free_array(void **array)
21 {
22
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (!array)
23 return;
24
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for (size_t i = 0; array[i]; i++)
25 2 secure_free((void **)&array[i]);
26 2 free(array);
27 array = NULL;
28 }
29
30 void print_string_array(char **array)
31 {
32 if (array == NULL) {
33 printf("Array is NULL\n");
34 return;
35 }
36 for (size_t i = 0; array[i]; i++) {
37 printf("%s\n", array[i]);
38 }
39 }
40