From 7746abd8e9ee9db20c0b0fdb19504f163ba3cbea Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 9 Dec 2015 12:34:02 +0000 Subject: qom: Change object property iterator API contract MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Daniel P. Berrange Reviewed-by: Markus Armbruster [AF: Fused ObjectPropertyIterator struct with typedef] Signed-off-by: Andreas Färber --- tests/check-qom-proplist.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index 5167e78..448d270 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -455,11 +455,11 @@ static void test_dummy_iterator(void) NULL)); ObjectProperty *prop; - ObjectPropertyIterator *iter; + ObjectPropertyIterator iter; bool seenbv = false, seensv = false, seenav = false, seentype; - iter = object_property_iter_init(OBJECT(dobj)); - while ((prop = object_property_iter_next(iter))) { + object_property_iter_init(&iter, OBJECT(dobj)); + while ((prop = object_property_iter_next(&iter))) { if (g_str_equal(prop->name, "bv")) { seenbv = true; } else if (g_str_equal(prop->name, "sv")) { @@ -474,7 +474,6 @@ static void test_dummy_iterator(void) g_assert_not_reached(); } } - object_property_iter_free(iter); g_assert(seenbv); g_assert(seenav); g_assert(seensv); -- cgit v1.1