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