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 10f2ad72b3SPeter Maydell #include "qemu/osdep.h" 1155e1819cSEric Blake #include "qemu-common.h" 12*c7eb39cbSEric Blake #include "qapi/qmp/types.h" 1355e1819cSEric Blake 147264f5c5SEric Blake static void (*qdestroy[QTYPE__MAX])(QObject *) = { 1555e1819cSEric Blake [QTYPE_NONE] = NULL, /* No such object exists */ 1655e1819cSEric Blake [QTYPE_QNULL] = NULL, /* qnull_ is indestructible */ 1755e1819cSEric Blake [QTYPE_QINT] = qint_destroy_obj, 1855e1819cSEric Blake [QTYPE_QSTRING] = qstring_destroy_obj, 1955e1819cSEric Blake [QTYPE_QDICT] = qdict_destroy_obj, 2055e1819cSEric Blake [QTYPE_QLIST] = qlist_destroy_obj, 2155e1819cSEric Blake [QTYPE_QFLOAT] = qfloat_destroy_obj, 2255e1819cSEric Blake [QTYPE_QBOOL] = qbool_destroy_obj, 2355e1819cSEric Blake }; 2455e1819cSEric Blake 2555e1819cSEric Blake void qobject_destroy(QObject *obj) 2655e1819cSEric Blake { 2755e1819cSEric Blake assert(!obj->refcnt); 287264f5c5SEric Blake assert(QTYPE_QNULL < obj->type && obj->type < QTYPE__MAX); 2955e1819cSEric Blake qdestroy[obj->type](obj); 3055e1819cSEric Blake } 31