[PATCH v2 14/41] util: firewall: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in
src/util/viralloc.h, define a new wrapper around an existing
cleanup function which will be called when a variable declared
with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant
viralloc.h include, since that has moved from the source module into
the header.

When a variable of type virFirewallPtr is declared using
VIR_AUTOPTR, the function virFirewallFree will be run
automatically on it when it goes out of scope.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@xxxxxxxxx>
Reviewed-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 src/util/virfirewall.c | 1 -
 src/util/virfirewall.h | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index 10c370a..dfd792f 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -27,7 +27,6 @@
 
 #include <stdarg.h>
 
-#include "viralloc.h"
 #include "virfirewallpriv.h"
 #include "virerror.h"
 #include "virutil.h"
diff --git a/src/util/virfirewall.h b/src/util/virfirewall.h
index b04ab48..e024e88 100644
--- a/src/util/virfirewall.h
+++ b/src/util/virfirewall.h
@@ -25,6 +25,7 @@
 # define __VIR_FIREWALL_H__
 
 # include "internal.h"
+# include "viralloc.h"
 
 typedef struct _virFirewall virFirewall;
 typedef virFirewall *virFirewallPtr;
@@ -116,4 +117,6 @@ int virFirewallApply(virFirewallPtr firewall);
 
 void virFirewallSetLockOverride(bool avoid);
 
+VIR_DEFINE_AUTOPTR_FUNC(virFirewall, virFirewallFree)
+
 #endif /* __VIR_FIREWALL_H__ */
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux