4 * Copyright (C) 2009 Red Hat Inc.
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.
15 #include "qemu-common.h"
17 static void qint_destroy_obj(QObject *obj);
19 static const QType qint_type = {
21 .destroy = qint_destroy_obj,
25 * qint_from_int(): Create a new QInt from an int64_t
27 * Return strong reference.
29 QInt *qint_from_int(int64_t value)
33 qi = g_malloc(sizeof(*qi));
35 QOBJECT_INIT(qi, &qint_type);
41 * qint_get_int(): Get the stored integer
43 int64_t qint_get_int(const QInt *qi)
49 * qobject_to_qint(): Convert a QObject into a QInt
51 QInt *qobject_to_qint(const QObject *obj)
53 if (qobject_type(obj) != QTYPE_QINT)
56 return container_of(obj, QInt, base);
60 * qint_destroy_obj(): Free all memory allocated by a
63 static void qint_destroy_obj(QObject *obj)
66 g_free(qobject_to_qint(obj));