155e1819cSEric Blake /* 255e1819cSEric Blake * QObject 355e1819cSEric Blake * 455e1819cSEric Blake * Copyright (C) 2015 Red Hat, Inc. 555e1819cSEric Blake * 655e1819cSEric Blake * This work is licensed under the terms of the GNU LGPL, version 2.1 755e1819cSEric Blake * or later. See the COPYING.LIB file in the top-level directory. 855e1819cSEric Blake */ 955e1819cSEric Blake 10*f2ad72b3SPeter Maydell #include "qemu/osdep.h" 1155e1819cSEric Blake #include "qemu-common.h" 1255e1819cSEric Blake #include "qapi/qmp/qbool.h" 1355e1819cSEric Blake #include "qapi/qmp/qdict.h" 1455e1819cSEric Blake #include "qapi/qmp/qfloat.h" 1555e1819cSEric Blake #include "qapi/qmp/qint.h" 1655e1819cSEric Blake #include "qapi/qmp/qlist.h" 1755e1819cSEric Blake #include "qapi/qmp/qstring.h" 1855e1819cSEric Blake 197264f5c5SEric Blake static void (*qdestroy[QTYPE__MAX])(QObject *) = { 2055e1819cSEric Blake [QTYPE_NONE] = NULL, /* No such object exists */ 2155e1819cSEric Blake [QTYPE_QNULL] = NULL, /* qnull_ is indestructible */ 2255e1819cSEric Blake [QTYPE_QINT] = qint_destroy_obj, 2355e1819cSEric Blake [QTYPE_QSTRING] = qstring_destroy_obj, 2455e1819cSEric Blake [QTYPE_QDICT] = qdict_destroy_obj, 2555e1819cSEric Blake [QTYPE_QLIST] = qlist_destroy_obj, 2655e1819cSEric Blake [QTYPE_QFLOAT] = qfloat_destroy_obj, 2755e1819cSEric Blake [QTYPE_QBOOL] = qbool_destroy_obj, 2855e1819cSEric Blake }; 2955e1819cSEric Blake 3055e1819cSEric Blake void qobject_destroy(QObject *obj) 3155e1819cSEric Blake { 3255e1819cSEric Blake assert(!obj->refcnt); 337264f5c5SEric Blake assert(QTYPE_QNULL < obj->type && obj->type < QTYPE__MAX); 3455e1819cSEric Blake qdestroy[obj->type](obj); 3555e1819cSEric Blake } 36