From 0bd54a10bd2eb886112f46c5cc99125fa9953481 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 7 Apr 2014 17:58:08 +0200 Subject: [PATCH] util: storagefile: Add function to free a virStorageSourcePtr Add a free function as some parts of the code will allocate the structure. --- src/libvirt_private.syms | 1 + src/util/virstoragefile.c | 11 +++++++++++ src/util/virstoragefile.h | 1 + 3 files changed, 13 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 972b184e3..f4ba406dd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1842,6 +1842,7 @@ virStorageNetHostTransportTypeToString; virStorageNetProtocolTypeToString; virStorageSourceAuthClear; virStorageSourceClear; +virStorageSourceFree; virStorageSourceGetActualType; virStorageSourcePoolDefFree; virStorageSourcePoolModeTypeFromString; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index f4d5b2cfd..4486b758e 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1719,3 +1719,14 @@ virStorageSourceClear(virStorageSourcePtr def) virStorageNetHostDefFree(def->nhosts, def->hosts); virStorageSourceAuthClear(def); } + + +void +virStorageSourceFree(virStorageSourcePtr def) +{ + if (!def) + return; + + virStorageSourceClear(def); + VIR_FREE(def); +} diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 2e9312f9d..0e5136e8a 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -333,5 +333,6 @@ void virStorageSourceAuthClear(virStorageSourcePtr def); void virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def); void virStorageSourceClear(virStorageSourcePtr def); int virStorageSourceGetActualType(virStorageSourcePtr def); +void virStorageSourceFree(virStorageSourcePtr def); #endif /* __VIR_STORAGE_FILE_H__ */ -- 2.39.5