[libvirt PATCH 09/10] qemuMonitorGetMemoryDeviceInfo: Use automatic memory management
Peter Krempa
pkrempa at redhat.com
Tue Jul 13 10:24:08 UTC 2021
On Fri, Jul 09, 2021 at 10:27:38 +0200, Tim Wiederhake wrote:
> Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
> ---
> src/qemu/qemu_monitor.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
> index 8646efe9c4..3a56ed8ef9 100644
> --- a/src/qemu/qemu_monitor.c
> +++ b/src/qemu/qemu_monitor.c
> @@ -4238,7 +4238,7 @@ int
> qemuMonitorGetMemoryDeviceInfo(qemuMonitor *mon,
> GHashTable **info)
> {
> - GHashTable *hash;
> + g_autoptr(GHashTable) hash = NULL;
> int ret;
>
> VIR_DEBUG("info=%p", info);
> @@ -4250,11 +4250,10 @@ qemuMonitorGetMemoryDeviceInfo(qemuMonitor *mon,
> if (!(hash = virHashNew(g_free)))
> return -1;
>
> - if ((ret = qemuMonitorJSONGetMemoryDeviceInfo(mon, hash)) < 0) {
> - virHashFree(hash);
> + if ((ret = qemuMonitorJSONGetMemoryDeviceInfo(mon, hash)) >= 0) {
> + *info = g_steal_pointer(&hash);
> }
>
> - *info = hash;
> return ret
This would probably look better when squashed into the previous commit.
More information about the libvir-list
mailing list