Simple shortcut to easily cleanup a stringsbuf.
---
daemon/daemon.h | 1 +
daemon/guestfsd.c | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 53cb797..bed4dbc 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -92,6 +92,7 @@ extern int add_string (struct stringsbuf *sb, const char *str);
extern int add_sprintf (struct stringsbuf *sb, const char *fs, ...)
__attribute__((format (printf,2,3)));
extern int end_stringsbuf (struct stringsbuf *sb);
+extern void free_stringsbuf (struct stringsbuf *sb);
extern size_t count_strings (char *const *argv);
extern void sort_strings (char **argv, size_t len);
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index c912ee3..453dee1 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -587,6 +587,13 @@ end_stringsbuf (struct stringsbuf *sb)
return add_string_nodup (sb, NULL);
}
+void
+free_stringsbuf (struct stringsbuf *sb)
+{
+ if (sb->argv != NULL)
+ free_stringslen (sb->argv, sb->size);
+}
+
size_t
count_strings (char *const *argv)
{
--
2.1.0