Branch data Line data Source code
1 : : #include "precizer.h"
2 : :
3 : : /**
4 : : * @brief Free a NULL-terminated pcre2_code pointer array and reset the caller-owned pointer
5 : : *
6 : : * @param[in,out] array_ptr Pointer to the array pointer to free.
7 : : *
8 : : * @note Passing `NULL` or a pointer to `NULL` is allowed
9 : : */
10 : 1662 : void free_compiled_array(pcre2_code ***array_ptr)
11 : : {
12 [ + - + + ]: 1662 : if(array_ptr == NULL || *array_ptr == NULL)
13 : : {
14 : 1472 : return;
15 : : }
16 : :
17 : 190 : pcre2_code **compiled_patterns = *array_ptr;
18 : :
19 [ + + ]: 408 : for(size_t i = 0; compiled_patterns[i] != NULL; i++)
20 : : {
21 : 218 : pcre2_code_free(compiled_patterns[i]);
22 : 218 : compiled_patterns[i] = NULL;
23 : : }
24 : :
25 : 190 : free(compiled_patterns);
26 : 190 : *array_ptr = NULL;
27 : : }
|