openocd: fix simple cases of Yoda condition
[fw/openocd] / src / helper / configuration.c
index 2a278838dedb348baa987151c5df684df9889706..8f4f118334f639297c41dbd088e8df4418e435af 100644 (file)
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include "configuration.h"
 #include "log.h"
+#include "replacements.h"
 
 static size_t num_config_files;
 static char **config_file_names;
@@ -51,6 +53,21 @@ void add_config_command(const char *cfg)
        config_file_names[num_config_files] = NULL;
 }
 
+void free_config(void)
+{
+       while (num_config_files)
+               free(config_file_names[--num_config_files]);
+
+       free(config_file_names);
+       config_file_names = NULL;
+
+       while (num_script_dirs)
+               free(script_search_dirs[--num_script_dirs]);
+
+       free(script_search_dirs);
+       script_search_dirs = NULL;
+}
+
 /* return full path or NULL according to search rules */
 char *find_file(const char *file)
 {