From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> Since we defined a custom virURIPtr type, we should use a virURIFree method instead of assuming it will always be a typedef for xmlURIPtr * src/util/viruri.c, src/util/viruri.h, src/libvirt_private.syms: Add a virURIFree method * src/datatypes.c, src/esx/esx_driver.c, src/libvirt.c, src/qemu/qemu_migration.c, src/vmx/vmx.c, src/xen/xend_internal.c, tests/viruritest.c: s/xmlFreeURI/virURIFree/ --- src/datatypes.c | 2 +- src/esx/esx_driver.c | 2 +- src/libvirt.c | 4 ++-- src/libvirt_private.syms | 1 + src/qemu/qemu_migration.c | 2 +- src/util/viruri.c | 12 ++++++++++++ src/util/viruri.h | 2 ++ src/vmx/vmx.c | 2 +- src/xen/xend_internal.c | 8 ++++---- tests/viruritest.c | 2 +- 10 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/datatypes.c b/src/datatypes.c index f0b5025..5ad988b 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -117,7 +117,7 @@ virReleaseConnect(virConnectPtr conn) { virResetError(&conn->err); - xmlFreeURI(conn->uri); + virURIFree(conn->uri); virMutexUnlock(&conn->lock); virMutexDestroy(&conn->lock); diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 6943534..dbf95f4 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -4072,7 +4072,7 @@ esxDomainMigratePerform(virDomainPtr domain, result = 0; cleanup: - xmlFreeURI(parsedUri); + virURIFree(parsedUri); esxVI_ObjectContent_Free(&virtualMachine); esxVI_Event_Free(&eventList); esxVI_ManagedObjectReference_Free(&task); diff --git a/src/libvirt.c b/src/libvirt.c index 7f8d42c..f58623a 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -5072,10 +5072,10 @@ virDomainMigratePeer2Peer (virDomainPtr domain, if (!tempuri->server || STRPREFIX(tempuri->server, "localhost")) { virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__); virDispatchError(domain->conn); - xmlFreeURI(tempuri); + virURIFree(tempuri); return -1; } - xmlFreeURI(tempuri); + virURIFree(tempuri); /* Perform the migration. The driver isn't supposed to return * until the migration is complete. diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e40c80e..7cd6a96 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1469,6 +1469,7 @@ virTypedParameterAssign; # viruri.h +virURIFree; virURIFormat; virURIParse; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 81b2d5b..6f274ba 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1875,7 +1875,7 @@ static int doNativeMigrate(struct qemud_driver *driver, if (spec.destType == MIGRATION_DEST_FD) VIR_FORCE_CLOSE(spec.dest.fd.qemu); - xmlFreeURI(uribits); + virURIFree(uribits); return ret; } diff --git a/src/util/viruri.c b/src/util/viruri.c index 6c4dfe3..0b25679 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -91,3 +91,15 @@ virURIFormat(xmlURIPtr uri) return ret; } + + +/** + * virURIFree: + * @uri: uri to free + * + * Frees the URI + */ +void virURIFree(virURIPtr uri) +{ + xmlFreeURI(uri); +} diff --git a/src/util/viruri.h b/src/util/viruri.h index 5215e42..80369be 100644 --- a/src/util/viruri.h +++ b/src/util/viruri.h @@ -19,4 +19,6 @@ typedef xmlURIPtr virURIPtr; virURIPtr virURIParse(const char *uri); char *virURIFormat(virURIPtr uri); +void virURIFree(virURIPtr uri); + #endif /* __VIR_URI_H__ */ diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index cc426da..3179688 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2696,7 +2696,7 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port, VIR_FREE(fileType); VIR_FREE(fileName); VIR_FREE(network_endPoint); - xmlFreeURI(parsedUri); + virURIFree(parsedUri); return result; diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index a19d055..df6b1bb 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -3234,25 +3234,25 @@ xenDaemonDomainMigratePerform (virDomainPtr domain, virXendError(VIR_ERR_INVALID_ARG, "%s", _("xenDaemonDomainMigrate: only xenmigr://" " migrations are supported by Xen")); - xmlFreeURI (uriptr); + virURIFree (uriptr); return -1; } if (!uriptr->server) { virXendError(VIR_ERR_INVALID_ARG, "%s", _("xenDaemonDomainMigrate: a hostname must be" " specified in the URI")); - xmlFreeURI (uriptr); + virURIFree (uriptr); return -1; } hostname = strdup (uriptr->server); if (!hostname) { virReportOOMError(); - xmlFreeURI (uriptr); + virURIFree (uriptr); return -1; } if (uriptr->port) snprintf (port, sizeof port, "%d", uriptr->port); - xmlFreeURI (uriptr); + virURIFree (uriptr); } else if ((p = strrchr (uri, ':')) != NULL) { /* "hostname:port" */ int port_nr, n; diff --git a/tests/viruritest.c b/tests/viruritest.c index a5de50a..0b38219 100644 --- a/tests/viruritest.c +++ b/tests/viruritest.c @@ -105,7 +105,7 @@ static int testURIParse(const void *args) ret = 0; cleanup: VIR_FREE(uristr); - xmlFreeURI(uri); + virURIFree(uri); return ret; } -- 1.7.7.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list