Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 69 lines (58 sloc) 1.237 kB
68396ea @rmustacc Initial commit of d32e8d0b8d9e0ef7cf7ab2e74548982972789dfc from qemu-kvm
rmustacc authored
1 /*
2 * QBool Module
3 *
4 * Copyright IBM, Corp. 2009
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *
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.
11 *
12 */
13
14 #include "qbool.h"
15 #include "qobject.h"
16 #include "qemu-common.h"
17
18 static void qbool_destroy_obj(QObject *obj);
19
20 static const QType qbool_type = {
21 .code = QTYPE_QBOOL,
22 .destroy = qbool_destroy_obj,
23 };
24
25 /**
26 * qbool_from_int(): Create a new QBool from an int
27 *
28 * Return strong reference.
29 */
30 QBool *qbool_from_int(int value)
31 {
32 QBool *qb;
33
34 qb = qemu_malloc(sizeof(*qb));
35 qb->value = value;
36 QOBJECT_INIT(qb, &qbool_type);
37
38 return qb;
39 }
40
41 /**
42 * qbool_get_int(): Get the stored int
43 */
44 int qbool_get_int(const QBool *qb)
45 {
46 return qb->value;
47 }
48
49 /**
50 * qobject_to_qbool(): Convert a QObject into a QBool
51 */
52 QBool *qobject_to_qbool(const QObject *obj)
53 {
54 if (qobject_type(obj) != QTYPE_QBOOL)
55 return NULL;
56
57 return container_of(obj, QBool, base);
58 }
59
60 /**
61 * qbool_destroy_obj(): Free all memory allocated by a
62 * QBool object
63 */
64 static void qbool_destroy_obj(QObject *obj)
65 {
66 assert(obj != NULL);
67 qemu_free(qobject_to_qbool(obj));
68 }
Something went wrong with that request. Please try again.