diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2018-04-19 17:01:43 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2018-05-04 08:27:53 +0200 |
commit | cb3e7f08aeaab0ab13e629ce8496dca150a449ba (patch) | |
tree | 189830b93bea625aac19f86f26dc4b04cd99f5a3 /qobject/qdict.c | |
parent | 3d3eacaeccaab718ea0e2ddaa578bfae9e311c59 (diff) |
qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF
Now that we can safely call QOBJECT() on QObject * as well as its
subtypes, we can have macros qobject_ref() / qobject_unref() that work
everywhere instead of having to use QINCREF() / QDECREF() for QObject
and qobject_incref() / qobject_decref() for its subtypes.
The replacement is mechanical, except I broke a long line, and added a
cast in monitor_qmp_cleanup_req_queue_locked(). Unlike
qobject_decref(), qobject_unref() doesn't accept void *.
Note that the new macros evaluate their argument exactly once, thus no
need to shout them.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180419150145.24795-4-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, semantic conflict resolved, commit message improved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'qobject/qdict.c')
-rw-r--r-- | qobject/qdict.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/qobject/qdict.c b/qobject/qdict.c index d1997a0d8a..2e9bd53e22 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -123,7 +123,7 @@ void qdict_put_obj(QDict *qdict, const char *key, QObject *value) entry = qdict_find(qdict, key, bucket); if (entry) { /* replace key's value */ - qobject_decref(entry->value); + qobject_unref(entry->value); entry->value = value; } else { /* allocate a new entry */ @@ -373,7 +373,7 @@ QDict *qdict_clone_shallow(const QDict *src) for (i = 0; i < QDICT_BUCKET_MAX; i++) { QLIST_FOREACH(entry, &src->table[i], next) { - qobject_incref(entry->value); + qobject_ref(entry->value); qdict_put_obj(dest, entry->key, entry->value); } } @@ -390,7 +390,7 @@ static void qentry_destroy(QDictEntry *e) assert(e->key != NULL); assert(e->value != NULL); - qobject_decref(e->value); + qobject_unref(e->value); g_free(e->key); g_free(e); } @@ -480,7 +480,7 @@ void qdict_copy_default(QDict *dst, QDict *src, const char *key) val = qdict_get(src, key); if (val) { - qobject_incref(val); + qobject_ref(val); qdict_put_obj(dst, key, val); } } @@ -526,7 +526,7 @@ static void qdict_flatten_qlist(QList *qlist, QDict *target, const char *prefix) qdict_flatten_qlist(qobject_to(QList, value), target, new_key); } else { /* All other types are moved to the target unchanged. */ - qobject_incref(value); + qobject_ref(value); qdict_put_obj(target, new_key, value); } @@ -566,7 +566,7 @@ static void qdict_flatten_qdict(QDict *qdict, QDict *target, const char *prefix) delete = true; } else if (prefix) { /* All other objects are moved to the target unchanged. */ - qobject_incref(value); + qobject_ref(value); qdict_put_obj(target, new_key, value); delete = true; } @@ -610,7 +610,7 @@ void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start) while (entry != NULL) { next = qdict_next(src, entry); if (strstart(entry->key, start, &p)) { - qobject_incref(entry->value); + qobject_ref(entry->value); qdict_put_obj(*dst, p, entry->value); qdict_del(src, entry->key); } @@ -684,7 +684,7 @@ void qdict_array_split(QDict *src, QList **dst) qdict_extract_subqdict(src, &subqdict, prefix); assert(qdict_size(subqdict) > 0); } else { - qobject_incref(subqobj); + qobject_ref(subqobj); qdict_del(src, indexstr); } @@ -894,7 +894,7 @@ QObject *qdict_crumple(const QDict *src, Error **errp) qdict_put_obj(two_level, prefix, QOBJECT(child_dict)); } - qobject_incref(ent->value); + qobject_ref(ent->value); qdict_put_obj(child_dict, suffix, ent->value); } else { if (child) { @@ -902,7 +902,7 @@ QObject *qdict_crumple(const QDict *src, Error **errp) prefix); goto error; } - qobject_incref(ent->value); + qobject_ref(ent->value); qdict_put_obj(two_level, prefix, ent->value); } @@ -924,11 +924,11 @@ QObject *qdict_crumple(const QDict *src, Error **errp) qdict_put_obj(multi_level, ent->key, child); } else { - qobject_incref(ent->value); + qobject_ref(ent->value); qdict_put_obj(multi_level, ent->key, ent->value); } } - QDECREF(two_level); + qobject_unref(two_level); two_level = NULL; /* Step 3: detect if we need to turn our dict into list */ @@ -951,10 +951,10 @@ QObject *qdict_crumple(const QDict *src, Error **errp) goto error; } - qobject_incref(child); + qobject_ref(child); qlist_append_obj(qobject_to(QList, dst), child); } - QDECREF(multi_level); + qobject_unref(multi_level); multi_level = NULL; } else { dst = QOBJECT(multi_level); @@ -964,9 +964,9 @@ QObject *qdict_crumple(const QDict *src, Error **errp) error: g_free(prefix); - QDECREF(multi_level); - QDECREF(two_level); - qobject_decref(dst); + qobject_unref(multi_level); + qobject_unref(two_level); + qobject_unref(dst); return NULL; } @@ -1055,7 +1055,7 @@ void qdict_join(QDict *dest, QDict *src, bool overwrite) next = qdict_next(src, entry); if (overwrite || !qdict_haskey(dest, entry->key)) { - qobject_incref(entry->value); + qobject_ref(entry->value); qdict_put_obj(dest, entry->key, entry->value); qdict_del(src, entry->key); } @@ -1088,7 +1088,7 @@ bool qdict_rename_keys(QDict *qdict, const QDictRenames *renames, Error **errp) } qobj = qdict_get(qdict, renames->from); - qobject_incref(qobj); + qobject_ref(qobj); qdict_put_obj(qdict, renames->to, qobj); qdict_del(qdict, renames->from); } |