Line data Source code
1 : #include "precizer.h"
2 :
3 : /**
4 : * Function to free the array
5 : *
6 : */
7 816 : STATIC void free_str_array(char **array)
8 : {
9 816 : if(array == NULL)
10 : {
11 734 : return;
12 : }
13 :
14 214 : for(size_t i = 0; array[i] != NULL; i++)
15 : {
16 132 : free(array[i]);
17 : }
18 82 : free(array);
19 : }
20 :
21 : /**
22 : *
23 : * Clean up allocated memory
24 : *
25 : */
26 203 : void free_config(void)
27 : {
28 : /// Enable key echo in terminal (return back
29 : /// default settings)
30 : struct termios term;
31 203 : tcgetattr(fileno(stdin),&term);
32 203 : term.c_lflag |= (ICANON|ECHO);
33 203 : tcsetattr(fileno(stdin),0,&term);
34 :
35 203 : free(config->running_dir);
36 :
37 203 : free(config->db_primary_file_path);
38 203 : config->db_primary_file_path = NULL;
39 :
40 203 : free(config->db_file_name);
41 203 : config->db_file_name = NULL;
42 :
43 : // Free memory of string array
44 203 : free_str_array((config)->db_file_names);
45 :
46 : // Free memory of string array
47 203 : free_str_array((config)->ignore);
48 :
49 : // Free memory of string array
50 203 : free_str_array((config)->include);
51 :
52 : // Free memory of string array
53 203 : free_str_array((config)->lock_checksum);
54 203 : }
|