summaryrefslogtreecommitdiffstats
path: root/qemu/qobject/qfloat.c
diff options
context:
space:
mode:
Diffstat (limited to 'qemu/qobject/qfloat.c')
-rw-r--r--qemu/qobject/qfloat.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/qemu/qobject/qfloat.c b/qemu/qobject/qfloat.c
index 7de0992db..d5da84770 100644
--- a/qemu/qobject/qfloat.c
+++ b/qemu/qobject/qfloat.c
@@ -11,17 +11,11 @@
*
*/
+#include "qemu/osdep.h"
#include "qapi/qmp/qfloat.h"
#include "qapi/qmp/qobject.h"
#include "qemu-common.h"
-static void qfloat_destroy_obj(QObject *obj);
-
-static const QType qfloat_type = {
- .code = QTYPE_QFLOAT,
- .destroy = qfloat_destroy_obj,
-};
-
/**
* qfloat_from_int(): Create a new QFloat from a float
*
@@ -32,8 +26,8 @@ QFloat *qfloat_from_double(double value)
QFloat *qf;
qf = g_malloc(sizeof(*qf));
+ qobject_init(QOBJECT(qf), QTYPE_QFLOAT);
qf->value = value;
- QOBJECT_INIT(qf, &qfloat_type);
return qf;
}
@@ -51,9 +45,9 @@ double qfloat_get_double(const QFloat *qf)
*/
QFloat *qobject_to_qfloat(const QObject *obj)
{
- if (qobject_type(obj) != QTYPE_QFLOAT)
+ if (!obj || qobject_type(obj) != QTYPE_QFLOAT) {
return NULL;
-
+ }
return container_of(obj, QFloat, base);
}
@@ -61,7 +55,7 @@ QFloat *qobject_to_qfloat(const QObject *obj)
* qfloat_destroy_obj(): Free all memory allocated by a
* QFloat object
*/
-static void qfloat_destroy_obj(QObject *obj)
+void qfloat_destroy_obj(QObject *obj)
{
assert(obj != NULL);
g_free(qobject_to_qfloat(obj));