Received: from eggs.gnu.org ([2001:4830:134:3::10]:39634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9UKs-00052M-Ds for qemu-devel@nongnu.org; Thu, 17 Dec 2015 03:54:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9UKo-00074M-9d for qemu-devel@nongnu.org; Thu, 17 Dec 2015 03:54:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50188) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9UKo-00073Z-4x for qemu-devel@nongnu.org; Thu, 17 Dec 2015 03:54:50 -0500 From: Markus Armbruster References: <1449664442-26080-1-git-send-email-berrange@redhat.com> Date: Thu, 17 Dec 2015 09:54:46 +0100 In-Reply-To: <1449664442-26080-1-git-send-email-berrange@redhat.com> (Daniel P. Berrange's message of "Wed, 9 Dec 2015 12:34:02 +0000") Message-ID: <877fkdzc89.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2] qom: change object property iterator API contract List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: Andreas =?utf-8?Q?F=C3=A4rber?= , qemu-devel@nongnu.org "Daniel P. Berrange" writes: > Currently the object property 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 [...] > diff --git a/include/qom/object.h b/include/qom/object.h > index 9630c5b..275a21b 100644 > --- a/include/qom/object.h > +++ b/include/qom/object.h > @@ -971,6 +971,11 @@ ObjectProperty *object_class_property_find(ObjectClass *klass, const char *name, > > typedef struct ObjectPropertyIterator ObjectPropertyIterator; > > +struct ObjectPropertyIterator { > + ObjectClass *nextclass; > + GHashTableIter iter; > +}; > + Please fuse the two declarations. Perhaps Andreas can do that on commit. > /** > * object_property_iter_init: > * @obj: the object Reviewed-by: Markus Armbruster