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 : 1365 : void free_compiled_array(pcre2_code ***array_ptr)
11 : : {
12 [ + - + + ]: 1365 : if(array_ptr == NULL || *array_ptr == NULL)
13 : : {
14 : 1255 : return;
15 : : }
16 : :
17 : 110 : pcre2_code **compiled_patterns = *array_ptr;
18 : :
19 [ + + ]: 248 : for(size_t i = 0; compiled_patterns[i] != NULL; i++)
20 : : {
21 : 138 : pcre2_code_free(compiled_patterns[i]);
22 : 138 : compiled_patterns[i] = NULL;
23 : : }
24 : :
25 : 110 : free(compiled_patterns);
26 : 110 : *array_ptr = NULL;
27 : : }
|