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