cope with printf macro definition in readline.c
[qemu/mdroth.git] / qbool.c
blob5ab734c2c78572deef55ea0292e8253b78699266
1 /*
2 * QBool Module
4 * Copyright (C) 2009 Red Hat Inc.
6 * Authors:
7 * Luiz Capitulino <lcapitulino@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
12 * Copyright IBM, Corp. 2009
14 * Authors:
15 * Anthony Liguori <aliguori@us.ibm.com>
17 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
18 * See the COPYING.LIB file in the top-level directory.
22 #include "qbool.h"
23 #include "qobject.h"
24 #include "qemu-common.h"
26 static void qbool_destroy_obj(QObject *obj);
28 static const QType qbool_type = {
29 .code = QTYPE_QBOOL,
30 .destroy = qbool_destroy_obj,
33 /**
34 * qbool_from_int(): Create a new QBool from an int
36 * Return strong reference.
38 QBool *qbool_from_int(int value)
40 QBool *qb;
42 qb = qemu_malloc(sizeof(*qb));
43 qb->value = value;
44 QOBJECT_INIT(qb, &qbool_type);
46 return qb;
49 /**
50 * qbool_get_int(): Get the stored int
52 int qbool_get_int(const QBool *qb)
54 return qb->value;
57 /**
58 * qobject_to_qbool(): Convert a QObject into a QBool
60 QBool *qobject_to_qbool(const QObject *obj)
62 if (qobject_type(obj) != QTYPE_QBOOL)
63 return NULL;
65 return container_of(obj, QBool, base);
68 /**
69 * qbool_destroy_obj(): Free all memory allocated by a
70 * QBool object
72 static void qbool_destroy_obj(QObject *obj)
74 assert(obj != NULL);
75 qemu_free(qobject_to_qbool(obj));