]> git.proxmox.com Git - mirror_qemu.git/blame - qobject/qobject.c
qdev: Use GList for global properties
[mirror_qemu.git] / qobject / qobject.c
CommitLineData
55e1819c
EB
1/*
2 * QObject
3 *
4 * Copyright (C) 2015 Red Hat, Inc.
5 *
6 * This work is licensed under the terms of the GNU LGPL, version 2.1
7 * or later. See the COPYING.LIB file in the top-level directory.
8 */
9
f2ad72b3 10#include "qemu/osdep.h"
55e1819c
EB
11#include "qemu-common.h"
12#include "qapi/qmp/qbool.h"
13#include "qapi/qmp/qdict.h"
14#include "qapi/qmp/qfloat.h"
15#include "qapi/qmp/qint.h"
16#include "qapi/qmp/qlist.h"
17#include "qapi/qmp/qstring.h"
18
7264f5c5 19static void (*qdestroy[QTYPE__MAX])(QObject *) = {
55e1819c
EB
20 [QTYPE_NONE] = NULL, /* No such object exists */
21 [QTYPE_QNULL] = NULL, /* qnull_ is indestructible */
22 [QTYPE_QINT] = qint_destroy_obj,
23 [QTYPE_QSTRING] = qstring_destroy_obj,
24 [QTYPE_QDICT] = qdict_destroy_obj,
25 [QTYPE_QLIST] = qlist_destroy_obj,
26 [QTYPE_QFLOAT] = qfloat_destroy_obj,
27 [QTYPE_QBOOL] = qbool_destroy_obj,
28};
29
30void qobject_destroy(QObject *obj)
31{
32 assert(!obj->refcnt);
7264f5c5 33 assert(QTYPE_QNULL < obj->type && obj->type < QTYPE__MAX);
55e1819c
EB
34 qdestroy[obj->type](obj);
35}