]>
git.proxmox.com Git - qemu.git/blob - qint.c
9a56906895a873c5d14c725d2f569adf9f635166
4 * Copyright (C) 2009 Red Hat Inc.
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.
14 #include "qemu-common.h"
16 static const QType qint_type
;
19 * qint_from_int(): Create a new QInt from an int64_t
21 * Return strong reference.
23 QInt
*qint_from_int(int64_t value
)
27 qi
= qemu_malloc(sizeof(*qi
));
29 QOBJECT_INIT(qi
, &qint_type
);
35 * qint_get_int(): Get the stored integer
37 int64_t qint_get_int(const QInt
*qi
)
43 * qobject_to_qint(): Convert a QObject into a QInt
45 QInt
*qobject_to_qint(const QObject
*obj
)
47 if (qobject_type(obj
) != QTYPE_QINT
)
50 return container_of(obj
, QInt
, base
);
54 * qint_destroy_obj(): Free all memory allocated by a
57 static void qint_destroy_obj(QObject
*obj
)
60 qemu_free(qobject_to_qint(obj
));
63 static const QType qint_type
= {
65 .destroy
= qint_destroy_obj
,