]> git.proxmox.com Git - mirror_qemu.git/blame - qobject/qobject.c
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging
[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 11#include "qemu-common.h"
c7eb39cb 12#include "qapi/qmp/types.h"
55e1819c 13
7264f5c5 14static void (*qdestroy[QTYPE__MAX])(QObject *) = {
55e1819c
EB
15 [QTYPE_NONE] = NULL, /* No such object exists */
16 [QTYPE_QNULL] = NULL, /* qnull_ is indestructible */
17 [QTYPE_QINT] = qint_destroy_obj,
18 [QTYPE_QSTRING] = qstring_destroy_obj,
19 [QTYPE_QDICT] = qdict_destroy_obj,
20 [QTYPE_QLIST] = qlist_destroy_obj,
21 [QTYPE_QFLOAT] = qfloat_destroy_obj,
22 [QTYPE_QBOOL] = qbool_destroy_obj,
23};
24
25void qobject_destroy(QObject *obj)
26{
27 assert(!obj->refcnt);
7264f5c5 28 assert(QTYPE_QNULL < obj->type && obj->type < QTYPE__MAX);
55e1819c
EB
29 qdestroy[obj->type](obj);
30}