4 * Copyright IBM, Corp. 2009
9 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
10 * See the COPYING.LIB file in the top-level directory.
14 #include "qapi/qmp/qbool.h"
15 #include "qapi/qmp/qobject.h"
16 #include "qemu-common.h"
18 static void qbool_destroy_obj(QObject *obj);
20 static const QType qbool_type = {
22 .destroy = qbool_destroy_obj,
26 * qbool_from_bool(): Create a new QBool from a bool
28 * Return strong reference.
30 QBool *qbool_from_bool(bool value)
34 qb = g_malloc(sizeof(*qb));
36 QOBJECT_INIT(qb, &qbool_type);
42 * qbool_get_bool(): Get the stored bool
44 bool qbool_get_bool(const QBool *qb)
50 * qobject_to_qbool(): Convert a QObject into a QBool
52 QBool *qobject_to_qbool(const QObject *obj)
54 if (qobject_type(obj) != QTYPE_QBOOL)
57 return container_of(obj, QBool, base);
61 * qbool_destroy_obj(): Free all memory allocated by a
64 static void qbool_destroy_obj(QObject *obj)
67 g_free(qobject_to_qbool(obj));