X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=qobject.h;h=d42386dde1394d9651c87d69665ffa2742f4cdea;hb=5bda29da18eb5104718cad9810b625a0105cb0d2;hp=80c85bad292ea8b904147be4d231b707f7985718;hpb=5a1a2356490399c9b7eb850f9065af554b18cfd1;p=qemu.git diff --git a/qobject.h b/qobject.h index 80c85bad2..d42386dde 100644 --- a/qobject.h +++ b/qobject.h @@ -8,8 +8,8 @@ * Authors: * Luiz Capitulino * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. * * QObject Reference Counts Terminology * ------------------------------------ @@ -37,6 +37,13 @@ typedef enum { QTYPE_NONE, + QTYPE_QINT, + QTYPE_QSTRING, + QTYPE_QDICT, + QTYPE_QLIST, + QTYPE_QFLOAT, + QTYPE_QBOOL, + QTYPE_QERROR, } qtype_code; struct QObject; @@ -56,16 +63,14 @@ typedef struct QObject { QObject base /* Get the 'base' part of an object */ -#define QOBJECT(obj) (&obj->base) +#define QOBJECT(obj) (&(obj)->base) /* High-level interface for qobject_incref() */ #define QINCREF(obj) \ - assert(obj != NULL); \ qobject_incref(QOBJECT(obj)) /* High-level interface for qobject_decref() */ #define QDECREF(obj) \ - assert(obj != NULL); \ qobject_decref(QOBJECT(obj)) /* Initialize an object to default values */ @@ -78,7 +83,8 @@ typedef struct QObject { */ static inline void qobject_incref(QObject *obj) { - obj->refcnt++; + if (obj) + obj->refcnt++; } /** @@ -87,7 +93,7 @@ static inline void qobject_incref(QObject *obj) */ static inline void qobject_decref(QObject *obj) { - if (--obj->refcnt == 0) { + if (obj && --obj->refcnt == 0) { assert(obj->type != NULL); assert(obj->type->destroy != NULL); obj->type->destroy(obj);