diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2015-12-09 12:34:02 +0000 |
---|---|---|
committer | Timothy Pearson <tpearson@raptorengineering.com> | 2019-11-29 19:28:25 -0600 |
commit | 843a9528139f84ac0cb68aa8b5baac0a4bdcf419 (patch) | |
tree | 9c97ced2fb48f7fc87be754fdf10d79555ee36c3 /vl.c | |
parent | 11942fb061ca0899be8ab046e4181326d3ce760b (diff) | |
download | hqemu-843a9528139f84ac0cb68aa8b5baac0a4bdcf419.zip hqemu-843a9528139f84ac0cb68aa8b5baac0a4bdcf419.tar.gz |
qom: Change object property iterator API contract
Currently the ObjectProperty iterator API works as follows:
ObjectPropertyIterator *iter;
iter = object_property_iter_init(obj);
while ((prop = object_property_iter_next(iter))) {
...
}
object_property_iter_free(iter);
This has the benefit that the ObjectPropertyIterator struct
can be opaque, but has the downside that callers need to
explicitly call a free function. It is also not in keeping
with iterator style used elsewhere in QEMU/GLib2.
This patch changes the API to use stack allocation instead:
ObjectPropertyIterator iter;
object_property_iter_init(&iter, obj);
while ((prop = object_property_iter_next(&iter))) {
...
}
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[AF: Fused ObjectPropertyIterator struct with typedef]
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -1535,14 +1535,14 @@ MachineInfoList *qmp_query_machines(Error **errp) static int machine_help_func(QemuOpts *opts, MachineState *machine) { ObjectProperty *prop; - ObjectPropertyIterator *iter; + ObjectPropertyIterator iter; if (!qemu_opt_has_help_opt(opts)) { return 0; } - iter = object_property_iter_init(OBJECT(machine)); - while ((prop = object_property_iter_next(iter))) { + object_property_iter_init(&iter, OBJECT(machine)); + while ((prop = object_property_iter_next(&iter))) { if (!prop->set) { continue; } @@ -1555,7 +1555,6 @@ static int machine_help_func(QemuOpts *opts, MachineState *machine) error_printf("\n"); } } - object_property_iter_free(iter); return 1; } |