4 * Copyright (C) 2009 Red Hat Inc.
7 * Luiz Capitulino <lcapitulino@redhat.com>
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.
13 #include "qapi/qmp/qint.h"
14 #include "qapi/qmp/qobject.h"
15 #include "qemu-common.h"
18 * qint_from_int(): Create a new QInt from an int64_t
20 * Return strong reference.
22 QInt
*qint_from_int(int64_t value
)
26 qi
= g_malloc(sizeof(*qi
));
27 qobject_init(QOBJECT(qi
), QTYPE_QINT
);
34 * qint_get_int(): Get the stored integer
36 int64_t qint_get_int(const QInt
*qi
)
42 * qobject_to_qint(): Convert a QObject into a QInt
44 QInt
*qobject_to_qint(const QObject
*obj
)
46 if (!obj
|| qobject_type(obj
) != QTYPE_QINT
) {
49 return container_of(obj
, QInt
, base
);
53 * qint_destroy_obj(): Free all memory allocated by a
56 void qint_destroy_obj(QObject
*obj
)
59 g_free(qobject_to_qint(obj
));