[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/15] QObject: Accept NULL
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 01/15] QObject: Accept NULL |
Date: |
Tue, 6 Oct 2009 21:26:58 -0300 |
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.
Signed-off-by: Luiz Capitulino <address@hidden>
---
qobject.h | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/qobject.h b/qobject.h
index 39b8649..dcc8c63 100644
--- a/qobject.h
+++ b/qobject.h
@@ -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);
--
1.6.5.rc2.17.gdbc1b
- [Qemu-devel] [PATCH v2 00/15]: Initial QObject conversion, Luiz Capitulino, 2009/10/06
- [Qemu-devel] [PATCH 02/15] Introduce QList, Luiz Capitulino, 2009/10/06
- [Qemu-devel] [PATCH 01/15] QObject: Accept NULL,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 03/15] Introduce QList unit-tests, Luiz Capitulino, 2009/10/06
- [Qemu-devel] [PATCH 04/15] monitor: Add user_print() to mon_cmd_t, Luiz Capitulino, 2009/10/06
- [Qemu-devel] [PATCH 05/15] monitor: Handle new and old style handlers, Luiz Capitulino, 2009/10/06
- [Qemu-devel] [PATCH 06/15] monitor: do_info(): handle new and old info handlers, Luiz Capitulino, 2009/10/06
- [Qemu-devel] [PATCH 07/15] monitor: Convert do_quit() do QObject, Luiz Capitulino, 2009/10/06
- [Qemu-devel] [PATCH 08/15] monitor: Convert do_stop() to QObject, Luiz Capitulino, 2009/10/06