4 * Copyright (C) 2012-2016 Red Hat, Inc.
5 * Copyright IBM, Corp. 2011
8 * Michael Roth <mdroth@linux.vnet.ibm.com>
10 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
11 * See the COPYING.LIB file in the top-level directory.
15 #include "qemu/osdep.h"
16 #include "qapi/dealloc-visitor.h"
17 #include "qapi/qmp/qnull.h"
18 #include "qemu/queue.h"
19 #include "qapi/visitor-impl.h"
21 struct QapiDeallocVisitor
26 static void qapi_dealloc_start_struct(Visitor
*v
, const char *name
, void **obj
,
27 size_t unused
, Error
**errp
)
31 static void qapi_dealloc_end_struct(Visitor
*v
, void **obj
)
38 static void qapi_dealloc_start_alternate(Visitor
*v
, const char *name
,
39 GenericAlternate
**obj
, size_t size
,
44 static void qapi_dealloc_end_alternate(Visitor
*v
, void **obj
)
51 static void qapi_dealloc_start_list(Visitor
*v
, const char *name
,
52 GenericList
**list
, size_t size
,
57 static GenericList
*qapi_dealloc_next_list(Visitor
*v
, GenericList
*tail
,
60 GenericList
*next
= tail
->next
;
65 static void qapi_dealloc_end_list(Visitor
*v
, void **obj
)
69 static void qapi_dealloc_type_str(Visitor
*v
, const char *name
, char **obj
,
77 static void qapi_dealloc_type_int64(Visitor
*v
, const char *name
, int64_t *obj
,
82 static void qapi_dealloc_type_uint64(Visitor
*v
, const char *name
,
83 uint64_t *obj
, Error
**errp
)
87 static void qapi_dealloc_type_bool(Visitor
*v
, const char *name
, bool *obj
,
92 static void qapi_dealloc_type_number(Visitor
*v
, const char *name
, double *obj
,
97 static void qapi_dealloc_type_anything(Visitor
*v
, const char *name
,
98 QObject
**obj
, Error
**errp
)
105 static void qapi_dealloc_type_null(Visitor
*v
, const char *name
,
106 QNull
**obj
, Error
**errp
)
113 static void qapi_dealloc_free(Visitor
*v
)
115 g_free(container_of(v
, QapiDeallocVisitor
, visitor
));
118 Visitor
*qapi_dealloc_visitor_new(void)
120 QapiDeallocVisitor
*v
;
122 v
= g_malloc0(sizeof(*v
));
124 v
->visitor
.type
= VISITOR_DEALLOC
;
125 v
->visitor
.start_struct
= qapi_dealloc_start_struct
;
126 v
->visitor
.end_struct
= qapi_dealloc_end_struct
;
127 v
->visitor
.start_alternate
= qapi_dealloc_start_alternate
;
128 v
->visitor
.end_alternate
= qapi_dealloc_end_alternate
;
129 v
->visitor
.start_list
= qapi_dealloc_start_list
;
130 v
->visitor
.next_list
= qapi_dealloc_next_list
;
131 v
->visitor
.end_list
= qapi_dealloc_end_list
;
132 v
->visitor
.type_int64
= qapi_dealloc_type_int64
;
133 v
->visitor
.type_uint64
= qapi_dealloc_type_uint64
;
134 v
->visitor
.type_bool
= qapi_dealloc_type_bool
;
135 v
->visitor
.type_str
= qapi_dealloc_type_str
;
136 v
->visitor
.type_number
= qapi_dealloc_type_number
;
137 v
->visitor
.type_any
= qapi_dealloc_type_anything
;
138 v
->visitor
.type_null
= qapi_dealloc_type_null
;
139 v
->visitor
.free
= qapi_dealloc_free
;