mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
qobject: Modify qobject_ref() to return obj
For convenience and clarity, make it possible to call qobject_ref() at the time when the reference is associated with a variable, or argument, by making qobject_ref() return the same pointer as given. Use that to simplify the callers. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180419150145.24795-5-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Useless change to qobject_ref_impl() dropped, commit message improved slightly] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
cb3e7f08ae
commit
f5a74a5a50
12 changed files with 47 additions and 64 deletions
|
@ -23,8 +23,7 @@ extern QNull qnull_;
|
|||
|
||||
static inline QNull *qnull(void)
|
||||
{
|
||||
qobject_ref(&qnull_);
|
||||
return &qnull_;
|
||||
return qobject_ref(&qnull_);
|
||||
}
|
||||
|
||||
bool qnull_is_equal(const QObject *x, const QObject *y);
|
||||
|
|
|
@ -103,8 +103,15 @@ static inline void qobject_unref_impl(QObject *obj)
|
|||
|
||||
/**
|
||||
* qobject_ref(): Increment QObject's reference count
|
||||
*
|
||||
* Returns: the same @obj. The type of @obj will be propagated to the
|
||||
* return type.
|
||||
*/
|
||||
#define qobject_ref(obj) qobject_ref_impl(QOBJECT(obj))
|
||||
#define qobject_ref(obj) ({ \
|
||||
typeof(obj) _o = (obj); \
|
||||
qobject_ref_impl(QOBJECT(_o)); \
|
||||
_o; \
|
||||
})
|
||||
|
||||
/**
|
||||
* qobject_unref(): Decrement QObject's reference count, deallocate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue