{
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;
*/
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;
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
ObjectProperty *object_class_property_find(ObjectClass *klass, const char *name,
Error **errp);
-typedef struct ObjectPropertyIterator ObjectPropertyIterator;
+typedef struct ObjectPropertyIterator {
+ ObjectClass *nextclass;
+ GHashTableIter iter;
+} ObjectPropertyIterator;
/**
* object_property_iter_init:
* <title>Using object property iterators</title>
* <programlisting>
* ObjectProperty *prop;
- * ObjectPropertyIterator *iter;
+ * ObjectPropertyIterator iter;
*
- * iter = object_property_iter_init(obj);
- * while ((prop = object_property_iter_next(iter))) {
+ * object_property_iter_init(&iter, obj);
+ * while ((prop = object_property_iter_next(&iter))) {
* ... do something with prop ...
* }
- * object_property_iter_free(iter);
* </programlisting>
* </example>
- *
- * Returns: the new iterator
*/
-ObjectPropertyIterator *object_property_iter_init(Object *obj);
-
-/**
- * object_property_iter_free:
- * @iter: the iterator instance
- *
- * Releases any resources associated with the iterator.
- */
-void object_property_iter_free(ObjectPropertyIterator *iter);
+void object_property_iter_init(ObjectPropertyIterator *iter,
+ Object *obj);
/**
* object_property_iter_next:
* @iter: the iterator instance
*
+ * Return the next available property. If no further properties
+ * are available, a %NULL value will be returned and the @iter
+ * pointer should not be used again after this point without
+ * re-initializing it.
+ *
* Returns: the next property, or %NULL when all properties
* have been traversed.
*/
Error *local_err = NULL;
char *str, *info;
ObjectProperty *prop;
- ObjectPropertyIterator *iter;
+ ObjectPropertyIterator iter;
StringOutputVisitor *ov;
if (!nf->netdev_id) {
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;
}
g_free(str);
g_free(info);
}
- object_property_iter_free(iter);
}
static void netfilter_finalize(Object *obj)
bool ambiguous = false;
ObjectPropertyInfoList *props = NULL;
ObjectProperty *prop;
- ObjectPropertyIterator *iter;
+ ObjectPropertyIterator iter;
obj = object_resolve_path(path, &ambiguous);
if (obj == NULL) {
return NULL;
}
- iter = object_property_iter_init(obj);
- while ((prop = object_property_iter_next(iter))) {
+ object_property_iter_init(&iter, obj);
+ while ((prop = object_property_iter_next(&iter))) {
ObjectPropertyInfoList *entry = g_malloc0(sizeof(*entry));
entry->value = g_malloc0(sizeof(ObjectPropertyInfo));
entry->value->name = g_strdup(prop->name);
entry->value->type = g_strdup(prop->type);
}
- object_property_iter_free(iter);
return props;
}
ObjectClass *klass;
Object *obj;
ObjectProperty *prop;
- ObjectPropertyIterator *iter;
+ ObjectPropertyIterator iter;
DevicePropertyInfoList *prop_list = NULL;
klass = object_class_by_name(typename);
obj = object_new(typename);
- iter = object_property_iter_init(obj);
- while ((prop = object_property_iter_next(iter))) {
+ object_property_iter_init(&iter, obj);
+ while ((prop = object_property_iter_next(&iter))) {
DevicePropertyInfo *info;
DevicePropertyInfoList *entry;
entry->next = prop_list;
prop_list = entry;
}
- object_property_iter_free(iter);
object_unref(obj);
InterfaceImpl interfaces[MAX_INTERFACES];
};
-struct ObjectPropertyIterator {
- ObjectClass *nextclass;
- GHashTableIter iter;
-};
-
static Type type_interface;
static GHashTable *type_table_get(void)
return NULL;
}
-ObjectPropertyIterator *object_property_iter_init(Object *obj)
+void object_property_iter_init(ObjectPropertyIterator *iter,
+ Object *obj)
{
- ObjectPropertyIterator *ret = g_new0(ObjectPropertyIterator, 1);
- g_hash_table_iter_init(&ret->iter, obj->properties);
- ret->nextclass = object_get_class(obj);
- return ret;
-}
-
-void object_property_iter_free(ObjectPropertyIterator *iter)
-{
- if (!iter) {
- return;
- }
- g_free(iter);
+ g_hash_table_iter_init(&iter->iter, obj->properties);
+ iter->nextclass = object_get_class(obj);
}
ObjectProperty *object_property_iter_next(ObjectPropertyIterator *iter)
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")) {
g_assert_not_reached();
}
}
- object_property_iter_free(iter);
g_assert(seenbv);
g_assert(seenav);
g_assert(seensv);
static int machine_help_func(QemuOpts *opts, MachineState *machine)
{
ObjectProperty *prop;
- ObjectPropertyIterator *iter;
+ ObjectPropertyIterator iter;
if (!qemu_opt_has_help_opt(opts)) {
return 0;
}
- iter = object_property_iter_init(OBJECT(machine));
- while ((prop = object_property_iter_next(iter))) {
+ object_property_iter_init(&iter, OBJECT(machine));
+ while ((prop = object_property_iter_next(&iter))) {
if (!prop->set) {
continue;
}
error_printf("\n");
}
}
- object_property_iter_free(iter);
return 1;
}