From: Kirill Shchetiniuk <[email protected]> Defined glib cleanup function for virStream object type and enabled the automatic memory management
Signed-off-by: Kirill Shchetiniuk <[email protected]> --- src/datatypes.h | 1 + src/qemu/qemu_migration.c | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index c5a7ece786..8dd4d87572 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -746,6 +746,7 @@ struct _virStream { virFreeCallback ff; }; +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStream, virObjectUnref); /** * _virDomainCheckpoint diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 9059f9aa3a..881133caed 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5564,13 +5564,13 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriver *driver, qemuMigrationParams *migParams) { virDomainPtr ddomain = NULL; - char *uri_out = NULL; - char *cookie = NULL; - char *dom_xml = NULL; + g_autofree char *uri_out = NULL; + g_autofree char *cookie = NULL; + g_autofree char *dom_xml = NULL; int cookielen = 0, ret; virErrorPtr orig_err = NULL; bool cancelled; - virStreamPtr st = NULL; + g_autoptr(virStream) st = NULL; unsigned long destflags; VIR_DEBUG("driver=%p, sconn=%p, dconn=%p, vm=%p, dconnuri=%s, " @@ -5616,7 +5616,7 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriver *driver, if (qemuDomainObjExitRemote(vm, true) < 0) goto cleanup; } - VIR_FREE(dom_xml); + if (ret == -1) goto cleanup; @@ -5680,11 +5680,7 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriver *driver, ret = -1; } - virObjectUnref(st); - virErrorRestore(&orig_err); - VIR_FREE(uri_out); - VIR_FREE(cookie); return ret; } -- 2.49.0
