diff mbox series

[v2,14/49] libmpathutil: add cleanup_vector()

Message ID 20240712171458.77611-15-mwilck@suse.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath-tools: devmapper API refactored | expand

Commit Message

Martin Wilck July 12, 2024, 5:14 p.m. UTC
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmpathutil/libmpathutil.version | 1 +
 libmpathutil/vector.c             | 6 ++++++
 libmpathutil/vector.h             | 1 +
 3 files changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/libmpathutil/libmpathutil.version b/libmpathutil/libmpathutil.version
index 86450f4..cb05231 100644
--- a/libmpathutil/libmpathutil.version
+++ b/libmpathutil/libmpathutil.version
@@ -136,4 +136,5 @@  LIBMPATHUTIL_2.1 {
 
 LIBMPATHUTIL_2.2 {
 	cleanup_udev_device;
+	cleanup_vector;
 };
diff --git a/libmpathutil/vector.c b/libmpathutil/vector.c
index df59db5..7c3ce43 100644
--- a/libmpathutil/vector.c
+++ b/libmpathutil/vector.c
@@ -169,6 +169,12 @@  vector_free(vector v)
 	free(v);
 }
 
+void cleanup_vector(vector *pv)
+{
+	if (*pv)
+		vector_free(*pv);
+}
+
 void
 free_strvec(vector strvec)
 {
diff --git a/libmpathutil/vector.h b/libmpathutil/vector.h
index c0b09cb..a41f157 100644
--- a/libmpathutil/vector.h
+++ b/libmpathutil/vector.h
@@ -78,6 +78,7 @@  extern vector vector_alloc(void);
 extern bool vector_alloc_slot(vector v);
 vector vector_reset(vector v);
 extern void vector_free(vector v);
+void cleanup_vector(vector *pv);
 #define vector_free_const(x) vector_free((vector)(long)(x))
 extern void free_strvec(vector strvec);
 extern void vector_set_slot(vector v, void *value);