4 * Copyright (C) 2009 Red Hat Inc.
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
14 #include "qemu-common.h"
16 static void qint_destroy_obj(QObject *obj);
18 static const QType qint_type = {
20 .destroy = qint_destroy_obj,
24 * qint_from_int(): Create a new QInt from an int64_t
26 * Return strong reference.
28 QInt *qint_from_int(int64_t value)
32 qi = qemu_malloc(sizeof(*qi));
34 QOBJECT_INIT(qi, &qint_type);
40 * qint_get_int(): Get the stored integer
42 int64_t qint_get_int(const QInt *qi)
48 * qobject_to_qint(): Convert a QObject into a QInt
50 QInt *qobject_to_qint(const QObject *obj)
52 if (qobject_type(obj) != QTYPE_QINT)
55 return container_of(obj, QInt, base);
59 * qint_destroy_obj(): Free all memory allocated by a
62 static void qint_destroy_obj(QObject *obj)
65 qemu_free(qobject_to_qint(obj));