diff options
author | Luiz Capitulino <lcapitulino@redhat.com> | 2009-10-07 13:41:47 -0300 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-10-08 21:17:17 -0500 |
commit | 4a9c5ec282c3d6a3e419927460c49e82a230d726 (patch) | |
tree | 73d9c53692a96ecc40490684d0e62c96d14171f7 /qobject.h | |
parent | c3a9dfaace7c3e94b74e60970cca513215d685c8 (diff) | |
download | qemu-4a9c5ec282c3d6a3e419927460c49e82a230d726.tar.gz qemu-4a9c5ec282c3d6a3e419927460c49e82a230d726.tar.bz2 qemu-4a9c5ec282c3d6a3e419927460c49e82a230d726.zip |
QObject: Accept NULL
It is convenient that QDECREF() and QINCREF() accept the QObject
parameter to be NULL, so that we don't duplicate 'if' tests in
the callers.
Patchworks-ID: 35332
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qobject.h')
-rw-r--r-- | qobject.h | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -63,12 +63,10 @@ typedef struct QObject { /* 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 */ @@ -81,7 +79,8 @@ typedef struct QObject { */ static inline void qobject_incref(QObject *obj) { - obj->refcnt++; + if (obj) + obj->refcnt++; } /** @@ -90,7 +89,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); |