982648
From 7b7b901fc909cc0536b4ae846b1ef741a01700c3 Mon Sep 17 00:00:00 2001
982648
Message-Id: <7b7b901fc909cc0536b4ae846b1ef741a01700c3@dist-git>
982648
From: Erik Skultety <eskultet@redhat.com>
982648
Date: Thu, 19 Jul 2018 15:03:51 +0200
982648
Subject: [PATCH] conf: Introduce virDomainVideoDefClear helper
982648
MIME-Version: 1.0
982648
Content-Type: text/plain; charset=UTF-8
982648
Content-Transfer-Encoding: 8bit
982648
982648
Future patches rely on the ability to reset the contents of the
982648
virDomainVideoDef structure rather than re-allocating it.
982648
982648
Signed-off-by: Erik Skultety <eskultet@redhat.com>
982648
Reviewed-by: John Ferlan <jferlan@redhat.com>
982648
(cherry picked from commit f317b1e5c57291644c841cb620eda86dac8642a1)
982648
982648
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
982648
Signed-off-by: Erik Skultety <eskultet@redhat.com>
982648
Reviewed-by: Ján Tomko <jtomko@redhat.com>
982648
---
982648
 src/conf/domain_conf.c   | 14 +++++++++++++-
982648
 src/conf/domain_conf.h   |  1 +
982648
 src/libvirt_private.syms |  1 +
982648
 3 files changed, 15 insertions(+), 1 deletion(-)
982648
982648
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
982648
index 70eb45f03a..d23b2861ef 100644
982648
--- a/src/conf/domain_conf.c
982648
+++ b/src/conf/domain_conf.c
982648
@@ -2538,7 +2538,8 @@ virDomainVideoDefNew(void)
982648
 }
982648
 
982648
 
982648
-void virDomainVideoDefFree(virDomainVideoDefPtr def)
982648
+void
982648
+virDomainVideoDefClear(virDomainVideoDefPtr def)
982648
 {
982648
     if (!def)
982648
         return;
982648
@@ -2548,6 +2549,17 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def)
982648
     VIR_FREE(def->accel);
982648
     VIR_FREE(def->virtio);
982648
     VIR_FREE(def->driver);
982648
+
982648
+    memset(def, 0, sizeof(*def));
982648
+}
982648
+
982648
+
982648
+void virDomainVideoDefFree(virDomainVideoDefPtr def)
982648
+{
982648
+    if (!def)
982648
+        return;
982648
+
982648
+    virDomainVideoDefClear(def);
982648
     VIR_FREE(def);
982648
 }
982648
 
982648
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
982648
index 41d27482fb..1fc1734bcc 100644
982648
--- a/src/conf/domain_conf.h
982648
+++ b/src/conf/domain_conf.h
982648
@@ -2884,6 +2884,7 @@ void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
982648
 void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
982648
 virDomainVideoDefPtr virDomainVideoDefNew(void);
982648
 void virDomainVideoDefFree(virDomainVideoDefPtr def);
982648
+void virDomainVideoDefClear(virDomainVideoDefPtr def);
982648
 virDomainHostdevDefPtr virDomainHostdevDefNew(void);
982648
 void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
982648
 void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
982648
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
982648
index 5499a368c0..5bd08d3f67 100644
982648
--- a/src/libvirt_private.syms
982648
+++ b/src/libvirt_private.syms
982648
@@ -567,6 +567,7 @@ virDomainTPMModelTypeToString;
982648
 virDomainUSBDeviceDefForeach;
982648
 virDomainVideoDefaultRAM;
982648
 virDomainVideoDefaultType;
982648
+virDomainVideoDefClear;
982648
 virDomainVideoDefFree;
982648
 virDomainVideoDefNew;
982648
 virDomainVideoTypeFromString;
982648
-- 
982648
2.18.0
982648