diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2015-12-09 12:34:02 +0000 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2016-01-18 17:47:58 +0100 |
commit | 7746abd8e9ee9db20c0b0fdb19504f163ba3cbea (patch) | |
tree | a5e9c56a0342b23cabe21e6bd199f312e1393fab /net | |
parent | 16bf7f522a2ff68993f80631ed86254c71eaf5d4 (diff) | |
download | qemu-7746abd8e9ee9db20c0b0fdb19504f163ba3cbea.zip |
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 'net')
-rw-r--r-- | net/filter.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/net/filter.c b/net/filter.c index f777ba2899..5d90f83429 100644 --- a/net/filter.c +++ b/net/filter.c @@ -137,7 +137,7 @@ static void netfilter_complete(UserCreatable *uc, Error **errp) Error *local_err = NULL; char *str, *info; ObjectProperty *prop; - ObjectPropertyIterator *iter; + ObjectPropertyIterator iter; StringOutputVisitor *ov; if (!nf->netdev_id) { @@ -174,8 +174,8 @@ static void netfilter_complete(UserCreatable *uc, Error **errp) QTAILQ_INSERT_TAIL(&nf->netdev->filters, nf, next); /* generate info str */ - iter = object_property_iter_init(OBJECT(nf)); - while ((prop = object_property_iter_next(iter))) { + object_property_iter_init(&iter, OBJECT(nf)); + while ((prop = object_property_iter_next(&iter))) { if (!strcmp(prop->name, "type")) { continue; } @@ -189,7 +189,6 @@ static void netfilter_complete(UserCreatable *uc, Error **errp) g_free(str); g_free(info); } - object_property_iter_free(iter); } static void netfilter_finalize(Object *obj) |