qmp-output-visitor: Favor new visit_free() function

Now that we have a polymorphic visit_free(), we no longer need
qmp_output_visitor_cleanup(); however, we still need to
expose the subtype for qmp_output_get_qobject().

Backports commit 1830f22a6777cedaccd67a08f675d30f7a85ebfd from qemu
This commit is contained in:
Eric Blake 2018-02-25 01:12:22 -05:00 committed by Lioncash
parent f008d93ac0
commit ec53301cda
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 5 additions and 12 deletions

View file

@ -20,7 +20,6 @@
typedef struct QmpOutputVisitor QmpOutputVisitor; typedef struct QmpOutputVisitor QmpOutputVisitor;
QmpOutputVisitor *qmp_output_visitor_new(void); QmpOutputVisitor *qmp_output_visitor_new(void);
void qmp_output_visitor_cleanup(QmpOutputVisitor *v);
QObject *qmp_output_get_qobject(QmpOutputVisitor *v); QObject *qmp_output_get_qobject(QmpOutputVisitor *v);
Visitor *qmp_output_get_visitor(QmpOutputVisitor *v); Visitor *qmp_output_get_visitor(QmpOutputVisitor *v);

View file

@ -218,21 +218,15 @@ Visitor *qmp_output_get_visitor(QmpOutputVisitor *v)
static void qmp_output_free(Visitor *v) static void qmp_output_free(Visitor *v)
{ {
QmpOutputVisitor *qov = to_qov(v); QmpOutputVisitor *qov = to_qov(v);
qmp_output_visitor_cleanup(qov);
}
void qmp_output_visitor_cleanup(QmpOutputVisitor *v)
{
QStackEntry *e, *tmp; QStackEntry *e, *tmp;
QTAILQ_FOREACH_SAFE(e, &v->stack, node, tmp) { QTAILQ_FOREACH_SAFE(e, &qov->stack, node, tmp) {
QTAILQ_REMOVE(&v->stack, e, node); QTAILQ_REMOVE(&qov->stack, e, node);
g_free(e); g_free(e);
} }
qobject_decref(v->root); qobject_decref(qov->root);
g_free(v); g_free(qov);
} }
QmpOutputVisitor *qmp_output_visitor_new(void) QmpOutputVisitor *qmp_output_visitor_new(void)

View file

@ -41,6 +41,6 @@ QObject *object_property_get_qobject(struct uc_struct *uc, Object *obj, const ch
ret = qmp_output_get_qobject(qov); ret = qmp_output_get_qobject(qov);
} }
error_propagate(errp, local_err); error_propagate(errp, local_err);
qmp_output_visitor_cleanup(qov); visit_free(qmp_output_get_visitor(qov));
return ret; return ret;
} }