diff mbox series

[v2,2/5] util: function to free an array of strings

Message ID 20181114160221.18242-3-sbabic@denx.de
State Accepted
Headers show
Series Support for links into sw-description. | expand

Commit Message

Stefano Babic Nov. 14, 2018, 4:02 p.m. UTC
Signed-off-by: Stefano Babic <sbabic@denx.de>
---

Changes in v2: None

 core/util.c    | 10 ++++++++++
 include/util.h |  1 +
 2 files changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/core/util.c b/core/util.c
index a357ea3..3ad0fd0 100644
--- a/core/util.c
+++ b/core/util.c
@@ -497,6 +497,16 @@  unsigned int count_string_array(const char **nodes)
 	return count;
 }
 
+void free_string_array(char **nodes)
+{
+	char **iter;
+	if (!nodes)
+		return;
+	for (iter = nodes; *iter != NULL; iter++)
+		free(*iter);
+	free(nodes);
+}
+
 unsigned long long ustrtoull(const char *cp, unsigned int base)
 {
 	errno = 0;
diff --git a/include/util.h b/include/util.h
index 0a95967..faf8aec 100644
--- a/include/util.h
+++ b/include/util.h
@@ -180,6 +180,7 @@  __u64 version_to_number(const char *version_string);
 int check_hw_compatibility(struct swupdate_cfg *cfg);
 int count_elem_list(struct imglist *list);
 unsigned int count_string_array(const char **nodes);
+void free_string_array(char **nodes);
 
 /* Decryption key functions */
 int load_decryption_key(char *fname);