qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] qom: change object property iterator API con


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v2] qom: change object property iterator API contract
Date: Thu, 17 Dec 2015 09:54:46 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

"Daniel P. Berrange" <address@hidden> 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 <address@hidden>
> Signed-off-by: Daniel P. Berrange <address@hidden>
[...]
> 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 <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]