[libvirt PATCH] conf: use correct free function for virDomainDeviceDef

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

 



Simple g_autofree is not enough if we put allocated
data into the device structure.

Define the AUTOPTR_CLEANUP function and use it here.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
Reported-by: Xu Yandong <xuyandong2@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 2 +-
 src/conf/domain_conf.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c95bd34fb5..c3214dc4f3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16516,7 +16516,7 @@ virDomainDeviceDefParse(const char *xmlStr,
     g_autoptr(xmlDoc) xml = NULL;
     xmlNodePtr node;
     g_autoptr(xmlXPathContext) ctxt = NULL;
-    g_autofree virDomainDeviceDefPtr dev = NULL;
+    g_autoptr(virDomainDeviceDef) dev = NULL;
 
     if (!(xml = virXMLParseStringCtxt(xmlStr, _("(device_definition)"), &ctxt)))
         return NULL;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index e144f3aad3..c3acb29e6f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2916,6 +2916,7 @@ void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
 void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
 void virDomainShmemDefFree(virDomainShmemDefPtr def);
 void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainDeviceDef, virDomainDeviceDefFree);
 virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
                                              const virDomainDef *def,
                                              virDomainXMLOptionPtr xmlopt,
-- 
2.21.0





[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