diff mbox series

[03/17] dictionary: add utility to drop the database

Message ID 1511176210-28928-3-git-send-email-sbabic@denx.de
State Accepted
Headers show
Series [01/17] parser: added function to get net child in tree | expand

Commit Message

Stefano Babic Nov. 20, 2017, 11:09 a.m. UTC
Add fucntion dict_drop_db() and call it from installer.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 corelib/installer.c     | 7 +++----
 corelib/swupdate_dict.c | 9 +++++++++
 include/swupdate_dict.h | 1 +
 3 files changed, 13 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/corelib/installer.c b/corelib/installer.c
index d2dee28..ae86d09 100644
--- a/corelib/installer.c
+++ b/corelib/installer.c
@@ -407,7 +407,6 @@  static void remove_sw_file(char __attribute__ ((__unused__)) *fname)
 void cleanup_files(struct swupdate_cfg *software) {
 	char fn[64];
 	struct img_type *img;
-	struct dict_entry *bootvar;
 	struct hw_type *hw;
 	const char* TMPDIR = get_tmpdir();
 
@@ -433,9 +432,9 @@  void cleanup_files(struct swupdate_cfg *software) {
 		LIST_REMOVE(img, next);
 		free(img);
 	}
-	LIST_FOREACH(bootvar, &software->bootloader, next) {
-		dict_remove_entry(bootvar);
-	}
+
+	dict_drop_db(&software->bootloader);
+
 	snprintf(fn, sizeof(fn), "%s%s", TMPDIR, BOOT_SCRIPT_SUFFIX);
 	remove_sw_file(fn);
 
diff --git a/corelib/swupdate_dict.c b/corelib/swupdate_dict.c
index 46e8203..4c8fb44 100644
--- a/corelib/swupdate_dict.c
+++ b/corelib/swupdate_dict.c
@@ -103,3 +103,12 @@  void dict_remove(struct dictlist *dictionary, char *key)
 
 	dict_remove_entry(entry);
 }
+
+void dict_drop_db(struct dictlist *dictionary)
+{
+	struct dict_entry *var;
+
+	LIST_FOREACH(var, dictionary, next) {
+		dict_remove_entry(var);
+	}
+}
diff --git a/include/swupdate_dict.h b/include/swupdate_dict.h
index 1bd2f5e..d8edb63 100644
--- a/include/swupdate_dict.h
+++ b/include/swupdate_dict.h
@@ -36,5 +36,6 @@  int dict_set_value(struct dictlist *dictionary, char *key, char *value);
 int dict_insert_entry(struct dictlist *dictionary, char *key, char *value);
 void dict_remove(struct dictlist *dictionary, char *key);
 void dict_remove_entry(struct dict_entry *entry);
+void dict_drop_db(struct dictlist *dictionary);
 
 #endif