mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 10:34:58 -06:00
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>
This commit is contained in:
parent
16bf7f522a
commit
7746abd8e9
7 changed files with 36 additions and 58 deletions
|
@ -684,7 +684,7 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner,
|
|||
{
|
||||
Object *root_container;
|
||||
ObjectProperty *prop;
|
||||
ObjectPropertyIterator *iter;
|
||||
ObjectPropertyIterator iter;
|
||||
uint32_t drc_count = 0;
|
||||
GArray *drc_indexes, *drc_power_domains;
|
||||
GString *drc_names, *drc_types;
|
||||
|
@ -708,8 +708,8 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner,
|
|||
*/
|
||||
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
|
||||
|
||||
iter = object_property_iter_init(root_container);
|
||||
while ((prop = object_property_iter_next(iter))) {
|
||||
object_property_iter_init(&iter, root_container);
|
||||
while ((prop = object_property_iter_next(&iter))) {
|
||||
Object *obj;
|
||||
sPAPRDRConnector *drc;
|
||||
sPAPRDRConnectorClass *drck;
|
||||
|
@ -750,7 +750,6 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner,
|
|||
spapr_drc_get_type_str(drc->type));
|
||||
drc_types = g_string_insert_len(drc_types, -1, "\0", 1);
|
||||
}
|
||||
object_property_iter_free(iter);
|
||||
|
||||
/* now write the drc count into the space we reserved at the
|
||||
* beginning of the arrays previously
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue