[PATCH v2 19/22] virDomainVideoDefNew: Use automatic memory management

Kirill Shchetiniuk via Devel posted 22 patches 2 weeks, 3 days ago
[PATCH v2 19/22] virDomainVideoDefNew: Use automatic memory management
Posted by Kirill Shchetiniuk via Devel 2 weeks, 3 days ago
From: Kirill Shchetiniuk <kshcheti@redhat.com>

Signed-off-by: Kirill Shchetiniuk <kshcheti@redhat.com>
---
 src/conf/domain_conf.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 14fb82e296..0b36a71dba 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3435,18 +3435,17 @@ void virDomainShmemDefFree(virDomainShmemDef *def)
 virDomainVideoDef *
 virDomainVideoDefNew(virDomainXMLOption *xmlopt)
 {
-    virDomainVideoDef *def;
+    g_autoptr(virDomainVideoDef) def = NULL;
 
     def = g_new0(virDomainVideoDef, 1);
 
     if (xmlopt && xmlopt->privateData.videoNew &&
         !(def->privateData = xmlopt->privateData.videoNew())) {
-        VIR_FREE(def);
         return NULL;
     }
 
     def->heads = 1;
-    return def;
+    return g_steal_pointer(&def);
 }
 
 
-- 
2.49.0