From f317b1e5c57291644c841cb620eda86dac8642a1 Mon Sep 17 00:00:00 2001 From: Erik Skultety Date: Thu, 28 Jun 2018 09:36:26 +0200 Subject: [PATCH] conf: Introduce virDomainVideoDefClear helper Future patches rely on the ability to reset the contents of the virDomainVideoDef structure rather than re-allocating it. Signed-off-by: Erik Skultety Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 14 +++++++++++++- src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7c9d04c924..43c288c7de 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2538,7 +2538,8 @@ virDomainVideoDefNew(void) } -void virDomainVideoDefFree(virDomainVideoDefPtr def) +void +virDomainVideoDefClear(virDomainVideoDefPtr def) { if (!def) return; @@ -2548,6 +2549,17 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def) VIR_FREE(def->accel); VIR_FREE(def->virtio); VIR_FREE(def->driver); + + memset(def, 0, sizeof(*def)); +} + + +void virDomainVideoDefFree(virDomainVideoDefPtr def) +{ + if (!def) + return; + + virDomainVideoDefClear(def); VIR_FREE(def); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 41d27482fb..1fc1734bcc 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2884,6 +2884,7 @@ void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def); void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def); virDomainVideoDefPtr virDomainVideoDefNew(void); void virDomainVideoDefFree(virDomainVideoDefPtr def); +void virDomainVideoDefClear(virDomainVideoDefPtr def); virDomainHostdevDefPtr virDomainHostdevDefNew(void); void virDomainHostdevDefClear(virDomainHostdevDefPtr def); void virDomainHostdevDefFree(virDomainHostdevDefPtr def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3e304907b9..e688981c3e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -558,6 +558,7 @@ virDomainTPMModelTypeToString; virDomainUSBDeviceDefForeach; virDomainVideoDefaultRAM; virDomainVideoDefaultType; +virDomainVideoDefClear; virDomainVideoDefFree; virDomainVideoDefNew; virDomainVideoTypeFromString; -- GitLab