Use virURIFree instead of xmlFreeURI

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/

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2012-03-20 11:59:42 +00:00
parent 6a7ffd4389
commit c33dae3175
10 changed files with 26 additions and 11 deletions

View File

@ -117,7 +117,7 @@ virReleaseConnect(virConnectPtr conn) {
virResetError(&conn->err); virResetError(&conn->err);
xmlFreeURI(conn->uri); virURIFree(conn->uri);
virMutexUnlock(&conn->lock); virMutexUnlock(&conn->lock);
virMutexDestroy(&conn->lock); virMutexDestroy(&conn->lock);

View File

@ -4072,7 +4072,7 @@ esxDomainMigratePerform(virDomainPtr domain,
result = 0; result = 0;
cleanup: cleanup:
xmlFreeURI(parsedUri); virURIFree(parsedUri);
esxVI_ObjectContent_Free(&virtualMachine); esxVI_ObjectContent_Free(&virtualMachine);
esxVI_Event_Free(&eventList); esxVI_Event_Free(&eventList);
esxVI_ManagedObjectReference_Free(&task); esxVI_ManagedObjectReference_Free(&task);

View File

@ -5071,10 +5071,10 @@ virDomainMigratePeer2Peer (virDomainPtr domain,
if (!tempuri->server || STRPREFIX(tempuri->server, "localhost")) { if (!tempuri->server || STRPREFIX(tempuri->server, "localhost")) {
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__); virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
virDispatchError(domain->conn); virDispatchError(domain->conn);
xmlFreeURI(tempuri); virURIFree(tempuri);
return -1; return -1;
} }
xmlFreeURI(tempuri); virURIFree(tempuri);
/* Perform the migration. The driver isn't supposed to return /* Perform the migration. The driver isn't supposed to return
* until the migration is complete. * until the migration is complete.

View File

@ -1472,6 +1472,7 @@ virTypedParameterAssign;
# viruri.h # viruri.h
virURIFormat; virURIFormat;
virURIFree;
virURIParse; virURIParse;

View File

@ -1956,7 +1956,7 @@ static int doNativeMigrate(struct qemud_driver *driver,
if (spec.destType == MIGRATION_DEST_FD) if (spec.destType == MIGRATION_DEST_FD)
VIR_FORCE_CLOSE(spec.dest.fd.qemu); VIR_FORCE_CLOSE(spec.dest.fd.qemu);
xmlFreeURI(uribits); virURIFree(uribits);
return ret; return ret;
} }

View File

@ -91,3 +91,15 @@ virURIFormat(xmlURIPtr uri)
return ret; return ret;
} }
/**
* virURIFree:
* @uri: uri to free
*
* Frees the URI
*/
void virURIFree(virURIPtr uri)
{
xmlFreeURI(uri);
}

View File

@ -19,4 +19,6 @@ typedef xmlURIPtr virURIPtr;
virURIPtr virURIParse(const char *uri); virURIPtr virURIParse(const char *uri);
char *virURIFormat(virURIPtr uri); char *virURIFormat(virURIPtr uri);
void virURIFree(virURIPtr uri);
#endif /* __VIR_URI_H__ */ #endif /* __VIR_URI_H__ */

View File

@ -2696,7 +2696,7 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
VIR_FREE(fileType); VIR_FREE(fileType);
VIR_FREE(fileName); VIR_FREE(fileName);
VIR_FREE(network_endPoint); VIR_FREE(network_endPoint);
xmlFreeURI(parsedUri); virURIFree(parsedUri);
return result; return result;

View File

@ -3234,25 +3234,25 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
virXendError(VIR_ERR_INVALID_ARG, virXendError(VIR_ERR_INVALID_ARG,
"%s", _("xenDaemonDomainMigrate: only xenmigr://" "%s", _("xenDaemonDomainMigrate: only xenmigr://"
" migrations are supported by Xen")); " migrations are supported by Xen"));
xmlFreeURI (uriptr); virURIFree (uriptr);
return -1; return -1;
} }
if (!uriptr->server) { if (!uriptr->server) {
virXendError(VIR_ERR_INVALID_ARG, virXendError(VIR_ERR_INVALID_ARG,
"%s", _("xenDaemonDomainMigrate: a hostname must be" "%s", _("xenDaemonDomainMigrate: a hostname must be"
" specified in the URI")); " specified in the URI"));
xmlFreeURI (uriptr); virURIFree (uriptr);
return -1; return -1;
} }
hostname = strdup (uriptr->server); hostname = strdup (uriptr->server);
if (!hostname) { if (!hostname) {
virReportOOMError(); virReportOOMError();
xmlFreeURI (uriptr); virURIFree (uriptr);
return -1; return -1;
} }
if (uriptr->port) if (uriptr->port)
snprintf (port, sizeof port, "%d", uriptr->port); snprintf (port, sizeof port, "%d", uriptr->port);
xmlFreeURI (uriptr); virURIFree (uriptr);
} }
else if ((p = strrchr (uri, ':')) != NULL) { /* "hostname:port" */ else if ((p = strrchr (uri, ':')) != NULL) { /* "hostname:port" */
int port_nr, n; int port_nr, n;

View File

@ -105,7 +105,7 @@ static int testURIParse(const void *args)
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(uristr); VIR_FREE(uristr);
xmlFreeURI(uri); virURIFree(uri);
return ret; return ret;
} }