util: storagefile: Add function to free a virStorageSourcePtr

Add a free function as some parts of the code will allocate the
structure.
This commit is contained in:
Peter Krempa 2014-04-07 17:58:08 +02:00
parent 39c5aa4e4c
commit 0bd54a10bd
3 changed files with 13 additions and 0 deletions

View File

@ -1842,6 +1842,7 @@ virStorageNetHostTransportTypeToString;
virStorageNetProtocolTypeToString; virStorageNetProtocolTypeToString;
virStorageSourceAuthClear; virStorageSourceAuthClear;
virStorageSourceClear; virStorageSourceClear;
virStorageSourceFree;
virStorageSourceGetActualType; virStorageSourceGetActualType;
virStorageSourcePoolDefFree; virStorageSourcePoolDefFree;
virStorageSourcePoolModeTypeFromString; virStorageSourcePoolModeTypeFromString;

View File

@ -1719,3 +1719,14 @@ virStorageSourceClear(virStorageSourcePtr def)
virStorageNetHostDefFree(def->nhosts, def->hosts); virStorageNetHostDefFree(def->nhosts, def->hosts);
virStorageSourceAuthClear(def); virStorageSourceAuthClear(def);
} }
void
virStorageSourceFree(virStorageSourcePtr def)
{
if (!def)
return;
virStorageSourceClear(def);
VIR_FREE(def);
}

View File

@ -333,5 +333,6 @@ void virStorageSourceAuthClear(virStorageSourcePtr def);
void virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def); void virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def);
void virStorageSourceClear(virStorageSourcePtr def); void virStorageSourceClear(virStorageSourcePtr def);
int virStorageSourceGetActualType(virStorageSourcePtr def); int virStorageSourceGetActualType(virStorageSourcePtr def);
void virStorageSourceFree(virStorageSourcePtr def);
#endif /* __VIR_STORAGE_FILE_H__ */ #endif /* __VIR_STORAGE_FILE_H__ */