aboutsummaryrefslogtreecommitdiff
path: root/qapi/qapi-dealloc-visitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'qapi/qapi-dealloc-visitor.c')
-rw-r--r--qapi/qapi-dealloc-visitor.c47
1 files changed, 3 insertions, 44 deletions
diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
index cd68b55a1a..9391dea203 100644
--- a/qapi/qapi-dealloc-visitor.c
+++ b/qapi/qapi-dealloc-visitor.c
@@ -19,53 +19,18 @@
#include "qapi/qmp/types.h"
#include "qapi/visitor-impl.h"
-typedef struct StackEntry
-{
- void *value;
- QTAILQ_ENTRY(StackEntry) node;
-} StackEntry;
-
struct QapiDeallocVisitor
{
Visitor visitor;
- QTAILQ_HEAD(, StackEntry) stack;
};
-static QapiDeallocVisitor *to_qov(Visitor *v)
-{
- return container_of(v, QapiDeallocVisitor, visitor);
-}
-
-static void qapi_dealloc_push(QapiDeallocVisitor *qov, void *value)
-{
- StackEntry *e = g_malloc0(sizeof(*e));
-
- e->value = value;
-
- QTAILQ_INSERT_HEAD(&qov->stack, e, node);
-}
-
-static void *qapi_dealloc_pop(QapiDeallocVisitor *qov)
-{
- StackEntry *e = QTAILQ_FIRST(&qov->stack);
- QObject *value;
- QTAILQ_REMOVE(&qov->stack, e, node);
- value = e->value;
- g_free(e);
- return value;
-}
-
static void qapi_dealloc_start_struct(Visitor *v, const char *name, void **obj,
size_t unused, Error **errp)
{
- QapiDeallocVisitor *qov = to_qov(v);
- qapi_dealloc_push(qov, obj);
}
-static void qapi_dealloc_end_struct(Visitor *v)
+static void qapi_dealloc_end_struct(Visitor *v, void **obj)
{
- QapiDeallocVisitor *qov = to_qov(v);
- void **obj = qapi_dealloc_pop(qov);
if (obj) {
g_free(*obj);
}
@@ -75,14 +40,10 @@ static void qapi_dealloc_start_alternate(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
bool promote_int, Error **errp)
{
- QapiDeallocVisitor *qov = to_qov(v);
- qapi_dealloc_push(qov, obj);
}
-static void qapi_dealloc_end_alternate(Visitor *v)
+static void qapi_dealloc_end_alternate(Visitor *v, void **obj)
{
- QapiDeallocVisitor *qov = to_qov(v);
- void **obj = qapi_dealloc_pop(qov);
if (obj) {
g_free(*obj);
}
@@ -102,7 +63,7 @@ static GenericList *qapi_dealloc_next_list(Visitor *v, GenericList *tail,
return next;
}
-static void qapi_dealloc_end_list(Visitor *v)
+static void qapi_dealloc_end_list(Visitor *v, void **obj)
{
}
@@ -178,7 +139,5 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void)
v->visitor.type_any = qapi_dealloc_type_anything;
v->visitor.type_null = qapi_dealloc_type_null;
- QTAILQ_INIT(&v->stack);
-
return v;
}